Hey folks, I’m scratching my head over here. I made a Discord bot using discord.js, but it’s ignoring my slash commands. I’ve set up the interactionCreate event and everything. Here’s a snippet of what I’m working with:
I’ve run into this issue before, and it can be frustrating. One thing that’s not mentioned yet is checking your bot’s presence status. Sometimes, if the bot shows as offline in Discord, it won’t respond to slash commands even if everything else is set up correctly.
Make sure your bot is actually connecting to Discord’s gateway. You can add a simple ‘ready’ event listener to confirm this:
bot.on(‘ready’, () => {
console.log(Logged in as ${bot.user.tag}!);
});
If you’re not seeing this log, there might be an issue with your bot token or internet connection. Also, double-check that you’re using the correct token in both your main bot file and the command registration script.
Lastly, try adding some console logs in your interactionCreate event to see if it’s being triggered at all. This can help narrow down where the problem is occurring.
hey mia92, did u check if ur bot has the right permissions? sometimes discord can be finicky with that stuff. also, make sure u’ve waited a bit after registering the commands, it can take a few mins to update. if that doesn’t work, try logging the interaction event to see if its even triggering
Have you registered your slash commands with Discord’s API? That’s a crucial step many overlook. You need to use the REST API to deploy commands to your server or globally. Here’s a quick example:
Run this script once to register commands. Also, ensure your bot has the ‘applications.commands’ scope when inviting it to servers. If issues persist, double-check your event handler and command execution logic.