I've written this bot to respond to a message with a prefix. The bot works, it connects to the server but it just doesn't reply to my message.
I don't understand why that is...
This is my code:
const { Client, GatewayIntentBits } = require('discord.js');
const config = require("./config.json");
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessageTyping,
]
});
client.on("ready", () => {
console.log("Bot is online!");
});
const prefix = "!";
client.on("message", message => {
if (message.author.bot) return;
if (!message.content.startsWith(prefix)) return;
const commandBody = message.content.slice(prefix.length);
const args = commandBody.split(" ");
const command = args.shift().toLowerCase();
if (command == "ping") {
message.reply("pong");
};
});
client.login(config.BOT_TOKEN);
I think it has something to do with the version.