Discord Bot Won't Detect User Interactions

I’m working on a Discord bot and having trouble getting it to respond to user interactions. The bot starts up fine and shows as online, but it doesn’t seem to catch any interactions at all.

The code runs without errors but nothing shows up in the console when users interact with the bot.

I’ve tried:

  • Messaging the bot directly
  • Posting in server channels
  • Mentioning the bot with @
  • Double checked my token is correct

The bot stays online even after I stop the script unless I regenerate the token. Not sure if that’s normal.

Here’s my basic setup:

const { Client, Intents } = require('discord.js');

const bot = new Client({ intents: [Intents.FLAGS.GUILDS] });

bot.once('ready', () => {
    console.log('Bot is online!');
});

bot.on('interactionCreate', event => {
    console.log(event);
});

bot.login(process.env.DISCORD_TOKEN);

My package.json looks like this:

{
    "name": "mybot",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
        "start": "node -r dotenv/config index.js dotenv_config_path=config.env",
        "test": "echo \"Error: no test specified\" && exit 1"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "dependencies": {
        "discord.js": "^13.1.0",
        "dotenv": "^10.0.0"
    }
}

What am I missing here? Any ideas what could be wrong?

Your intent setup is too restrictive. GUILDS intent only handles server events like joining or leaving - it won’t catch user messages or interactions. You need MESSAGE_CONTENT and GUILD_MESSAGES intents to detect direct messages and channel posts. If you’re specifically going for slash commands, you may skip message intents and register the commands through Discord’s API or development portal first. The behavior of your bot remaining online after stopping the script is normal; Discord keeps the connection alive momentarily before timing out. Try expanding your intents to [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.MESSAGE_CONTENT] to see if that resolves the detection issue.

you’re missing the slash command registration, interactionCreate only fires for registed slash commands, not regular msg. U gotta create and register ur cmds first, either in the discord dev portal or in ur code. also check ur bot’s perms in the server.

The problem is interactionCreate only fires for slash commands, not regular messages. Since you’re testing with DMs and channel posts, you need messageCreate instead. Add bot.on('messageCreate', message => { console.log(message.content); }); to your code plus the message intents others mentioned. I had the same confusion starting out - the docs don’t make it clear that interactions and messages are totally different things. Also, if you want slash commands later, you’ll need to register them through Discord’s API first or interactionCreate won’t trigger.