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

595
Views
¿Cómo arreglo mi bot de discordia (en discord.js) que no responde a mis comandos?

He estado tratando de hacer que mi bot de discord funcione, pero solo se conectará en discord y dirá que está en línea en la consola. Qué estoy haciendo mal

aquí está el código de mi index.js

 const Discord = require('discord.js') const client = new Discord.Client({ partials: ["MESSAGE", "CHANNEL", "REACTION" ], intents: ["GUILDS", /* Other intents... */]}); const token = '(token here)'; client.login(token); client.on('ready', () => { console.log('I ARRIVE FROM THE ASHES OF THE EARTH'); }); client.on('message', message => { if (message.content === 'Hello') { message.send('I HAVE A GUN'); } }); client.on('disconnect', () => { console.log('ZE POPCORN IS DEAD'); }); const prefix = '-'; client.on('message', message => { if (message.content === prefix + 'ping') { message.send('Gun').then(message => message.edit('Pong')); } }); client.on('message', message => { if (message.content === prefix + 'shutdown') { if (message.author.id === '262707958646901248') { message.send('Shutting down...').then(message => client.destroy()); } } }); client.on('message', message => { if (message.content.startsWith(prefix)) { const args = message.content.slice(prefix.length).split(/ +/); const command = args.shift().toLowerCase(); if (command === 'ping') { message.send('Gun'); } } }); client.on('message', message => { if (message.content === prefix + 'help') { message.send('figure it out I guess?'); } }); client.on('message', message => { if (message.content === prefix + 'info') { message.send('I made this bot when popcorn "died". I hope you enjoy it.'); } }); client.on('message', message => { if (message.content === 'ping') { message.send('https://tenor.com/view/heavy-tf2-the-rock-rock-the-rock-the-dwayne-johnson-gif-22149531'); } });

Probé todos los comandos que puse y tal, pero no hizo nada.

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

0

El código necesita bastante trabajo, principalmente en la organización. Además, tómese un minuto para familiarizarse con todo este sitio, ya que todos los diferentes elementos están aquí y es una herramienta que usará con frecuencia.

discordia v13 https://discord.js.org/#/docs/discord.js/v13/general/welcome

discordia v12 https://discord.js.org/#/docs/discord.js/v12/general/welcome

 const Discord = require('discord.js') const client = new Discord.Client({ partials: ["MESSAGE", "CHANNEL", "REACTION"], intents: ["GUILDS", "GUILD_MESSAGES" /* Other intents... */ ] // make sure GUILD_MESSAGES is in there }); const prefix = '-'; const token = '(token here)'; client.login(token); client.on('disconnect', () => { console.log('ZE POPCORN IS DEAD'); }); client.on('ready', () => { console.log('I ARRIVE FROM THE ASHES OF THE EARTH'); }); client.on('message', async message => { // add async const content = message.content.toLowerCase() // For readability // message.send will not work, it needs to be either message.channel.send() or message.reply() // these will work without prefix if (content === 'hello') { message.reply('I HAVE A GUN'); } else if (content === 'ping') { // Below will just send the link message.reply('https://tenor.com/view/heavy-tf2-the-rock-rock-the-rock-the-dwayne-johnson-gif-22149531'); // Below will send the attachment message.reply({ attachments: 'https://tenor.com/view/heavy-tf2-the-rock-rock-the-rock-the-dwayne-johnson-gif-22149531' }) } // these will require the prefix if (content.startsWith(prefix)) { const args = message.content.slice(prefix.length).split(/ +/); const command = args.shift().toLowerCase(); if (command === 'ping') { message.reply('Gun'); } else if (command === 'shutdown') { if (message.author.id === '262707958646901248') { message.reply('Shutting down...').then(() => client.destroy()); // message not used, so not required } else { message.reply('Not allowed') // added else statement } } else if (command === 'help') { message.reply('figure it out I guess?'); } else if (command === 'info') { message.reply('I made this bot when popcorn "died". I hope you enjoy it.'); } } });
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!