Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

226
Views
Discord Bot Not Receiving Interactions

I'm a relatively experienced developer (graduated recently), trying to get back into discord bots after I made a few a couple of years ago.

I've been following the guide on discordjs.guide, but even with the basic "hello world" style program, I am already stuck.

The program gives no errors when running, but no interactions come through in the console.

  • When I start the script, the bot switches to "online." Curiously, the bot does not switch back to "offline" until I regenerate the token. Not sure if that is related.
  • I've verified process.env.BOT_TOKEN is the correct value.
  • I've confirmed client.login runs successfully.
  • I've tried DMing the bot directly
  • I've tried sending messages on guild channels
  • I've tried @ing the bot

Is there something super obvious I'm not understanding/seeing? Otherwise, what else should I try as a troubleshooting step?

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

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

client.once('ready', () => {
    console.log('Ready!');
});

client.on('interactionCreate', interaction => {
    console.log(interaction);
});

client.login(process.env.BOT_TOKEN);

package.json:

{
    "name": "timebot",
    "version": "1.0.0",
    "description": "",
    "main": "start.js",
    "scripts": {
        "start": "node -r dotenv/config start.js dotenv_config_path=secrets.env",
        "test": "echo \"Error: no test specified\" && exit 1"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "dependencies": {
        "discord.js": "^13.1.0",
        "dotenv": "^10.0.0"
    }
}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Turns out, messages are not classified as "interactions" by discord.js. Additionally, you have to specify the intent to listen for messages, otherwise, the event won't be passed to your bot. Here is the revised code with those two critical changes:

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

const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.DIRECT_MESSAGES] });

client.once('ready', () => {
    console.log('Ready!');
});

client.on('interactionCreate', interaction => {
    console.log(interaction);
});

client.on("messageCreate", message => {
    console.log(message);
});

client.login(process.env.BOT_TOKEN);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!