Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

234
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda