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

556
Views
¿Por qué el chatbot de Discord en JavaScript no responde?

Estoy trabajando en este simple chatbot siguiendo el tutorial de Discord.

El chatbot ha iniciado sesión en mi servidor... Escribo en la sala de chat en Discord 'ping', pero el chatbot no responde "Pong" como debería.

A continuación se muestra el código main.js:

 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');

Nota: tengo un token secreto donde tiene 'token'

En mi terminal dice Logged in as Quote.it#4979! y mi bot está en línea cuando lo veo en el servidor en Discord.

Pero no pasa nada cuando en Discord escribo en 'ping'. ¿Cómo puedo diagnosticar mejor lo que está pasando?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Veo un par de problemas aquí, primero, no parece que estés registrando el comando ping, mira aquí , y segundo, no tienes las intenciones correctas, necesitas el GUILD_MESSAGES, mira aquí .

Aquí hay un simple bot de ping pong:

 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 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!