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

301
Views
El comando de tiempo de respuesta del bot de ping no funciona

¿Por qué este comando no funciona? Soy nuevo en la codificación y realmente agradecería un poco de ayuda. Simplemente estoy tratando de obtener un comando de ping de tiempo de respuesta del bot para que funcione. Esto ya no produce ningún error, pero tampoco funciona. obteniendo algún error Tengo dificultades para descubrir el problema por mi cuenta.

 client.on('messageCreate', message => { if (message.channel.type != 'text' || message.author.bot) return; let command = message.content.split(' ')[0].slice(1); let args = message.content.replace('.' + command, '').trim(); switch (command) { case 'ping': { message.channel.send('Pong! (~ ' + client.ping + 'ms)'); break; } case 'uptime': { // client.uptime is in millseconds // this is just maths, I won't explain much of it // % is modulo, AKA the remainder of a division let days = Math.floor(client.uptime / 86400000); let hours = Math.floor(client.uptime / 3600000) % 24; let minutes = Math.floor(client.uptime / 60000) % 60; let seconds = Math.floor(client.uptime / 1000) % 60; message.channel.send(`__Uptime:__\n${days}d ${hours}h ${minutes}m ${seconds}s`); break; } } });
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

El problema es que está comprobando si GuildChannel#type es text , que no es un ChannelType válido.

En su lugar, intente usar GUILD_TEXT .

 client.on('messageCreate', message => { if (message.channel.type !== 'GUILD_TEXT' || message.author.bot) return; let command = message.content.split(' ')[0].slice(1); let args = message.content.replace('.' + command, '').trim(); switch (command) { case 'ping': { message.channel.send('Pong! (~ ' + client.ping + 'ms)'); break; } case 'uptime': { // client.uptime is in millseconds // this is just maths, I won't explain much of it // % is modulo, AKA the remainder of a division let days = Math.floor(client.uptime / 86400000); let hours = Math.floor(client.uptime / 3600000) % 24; let minutes = Math.floor(client.uptime / 60000) % 60; let seconds = Math.floor(client.uptime / 1000) % 60; message.channel.send(`__Uptime:__\n${days}d ${hours}h ${minutes}m ${seconds}s`); break; } } });

Nota : en abril de 2022, el acceso al contenido del mensaje se convertirá en una intención privilegiada. Realmente te recomiendo que cambies a Slash Commands .

Lea más aquí:Message Content: Privileged Intent for Verified Bots

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