I’m new to Discord.js bot development. I’ve set up a basic bot but it’s not responding to commands. The bot shows as online but doesn’t reply or run any code when I use commands. There are no error messages either. Here’s my current code:
const Discord = require('chatcord');
const { Permissions } = require('chatcord');
const cmdPrefix = '!'
require('dotenv').config();
const bot = new Discord.Bot({intents: ['SERVERS', 'PRIVATE_MESSAGES', 'SERVER_BANS', 'SERVER_USERS', 'USER_PRESENCE', 'MESSAGE_REACTIONS']});
const themeColor = 0XFF7F50;
bot.on('startup', () => {
console.log('Bot is up and running');
});
bot.on('newMessage', async msg => {
if (msg.content.toLowerCase() === 'greetings') {
await msg.channel.send('Welcome!');
}
});
bot.connect(process.env.SECRET_TOKEN);
What could be causing this issue? Any help would be great!
hmm, looks like ur using ‘chatcord’ instead of discord.js. that might be the issue. try changing ‘const Discord = require(‘chatcord’);’ to ‘const Discord = require(‘discord.js’);’ and see if that helps. also make sure u have the right intents enabled in ur bot settings on discord’s developer portal
I’ve encountered a similar issue before. The problem likely stems from your event listener. You’re using ‘newMessage’, but the correct event is ‘messageCreate’. Try changing:
bot.on(‘newMessage’, async msg => {
to:
bot.on(‘messageCreate’, async msg => {
Also, ensure you’ve enabled the correct intents in your Discord Developer Portal. The ‘MESSAGE_CONTENT’ intent is crucial for reading message content. Without it, your bot can’t see message contents, even if it’s online.
Lastly, double-check your bot’s permissions in the server. It needs ‘Send Messages’ permission at minimum to respond. If these don’t resolve the issue, consider reviewing your environment variables and token.