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

551
Vistas
Why won't Discord chatbot in JavaScript respond?

I am working on this simple chatbot following the discord tutorial.

The chatbot has logged in to my server... I type in the chat room on Discord 'ping,' but the chatbot does not respond "Pong" as it should.

Below is the main.js code:

const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('interactionCreate', async interaction => {
  if (!interaction.isCommand()) return;

  if (interaction.commandName === 'ping') {
      console.log("we got a hello!")
    await interaction.reply('Pong!');
  }
});

client.login('token');

Note: I have a secret token where it has 'token'

In my Terminal it says Logged in as Quote.it#4979! and my bot is online when I view it in the server in Discord.

But nothing happens when in Discord I write in 'ping'. How can I better diagnose what is going on?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I see a couple of problems here, first, it doesn’t look like you are registering the ping command see here, and second, you don’t have the right intents, you need the GUILD_MESSAGES one see here.

Here’s a simple ping pong bot:

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

const client = new Client({
    intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
    partials: ['CHANNEL', 'MESSAGE'],
})

client.on('ready', () => {
    console.log(`Logged in as ${client.user.tag}!`)
})

client.on('messageCreate', (message) => {
    if (message.content.startsWith('ping')) {
        message.channel.send('pong!')
    }
})

client.login('token')
about 4 years ago · Juan Pablo Isaza 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