Discord Bot won't reply
I've being doing discord.js bot development for about 5 days, but not ever started over like I am now. I set up everything, and wanted to test if my bot was working so I added the command but for some reason the bot doesn't reply / run the code. It doesn't give an error even though the bots also online, does anyone know the solution?
const { info } = require("console");
const Discord = require("discord.js");
const { Permissions } = require("discord.js");
const { cp } = require("fs");
const prefix = "."
require("fs");
require("dotenv").config();
const client = new Discord.Client({intents : ["GUILDS", "DIRECT_MESSAGES", "GUILD_BANS", "GUILD_MEMBERS", "GUILD_PRESENCES", "GUILD_MESSAGE_REACTIONS"]});
const embedColor = 0X2B78FF;
client.on('ready', () => {
console.log("ready");
})
client.on('messageCreate', async message => {
if (message.content.toLowerCase() === 'hello') {
await message.channel.send("hi")
}
})
client.login(process.env.BOT_TOKEN)
Just like Zsolt commented already, you have every Intent that you would need generally there but you are missing one "essential" intent, and that is GUILD_MESSAGES
, so for clarity. Your bot does not "see" your message. Adding that to your const client = new Discord.Client({intents : []})
will fix the issue.
Also keep in mind that in Discord's Developer Portal, there are intents aswell. They introduced new intent not long ago, so you should check that too to avoid issues in the future.