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

119
Vistas
Discord.js no devuelve correctamente la cantidad de ciertas reacciones en un mensaje

Actualmente estoy codificando un bot de discordia con la biblioteca discord.js. Actualmente estoy agregando el comando de encuesta. El usuario ingresará algo parecido a esto

sh.poll (Cantidad de tiempo que la encuesta permanecerá abierta) (El contenido de la encuesta)

Todo el resto del código funciona bien, puede leer correctamente la cantidad de tiempo que ingresa el usuario y puede leer el texto que se supone que debe mostrar la encuesta. El problema surge cuando la encuesta tiene que cerrar.

El bot comenzará leyendo las reacciones que se encuentran actualmente en la encuesta, luego mostrará si la encuesta tuvo éxito o no. Sin embargo, comando que estoy usando:

Message.reactions.cache.get('Carácter Unicode').count

Siempre devuelve 1.

Siento que hay algo muy simple que me estoy perdiendo, pero simplemente no puedo encontrarlo.

 message.channel.send(message.content.slice(9 + message.content.split(' ')[1].length)).then(sent => { // Gets the message the user wants to send and sends it, also records the message ID in the sent var. message.delete(); // Deletes the original command message sent.react('👍'); // Adds reactions to the message sent by the bot sent.react('👎'); // Adds reactions to the message sent by the bot setTimeout(function(){ // Waits an amount of time determined earlier in the code console.log(sent.reactions.cache.get('👍').count); // This is the main command with the problem, always will print out 1 even if there are 2 or 3 reactions added } }, waitTime); })
 client.on('messageCreate', message => { if (!message.content.startsWith(prefix) || message.author.bot) { return; } const args = message.content.slice(prefix.length).split(/ +/); // Takes out the prefix const command = args.shift().toLowerCase(); // Makes the text lowercase } else if (command.startsWith('poll')) { // If the message had the command poll client.commands.get('Poll').execute(message, args); // Executes the code shown above
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Obtenga el mensaje una vez que se haya cerrado la encuesta (una vez que se haya ejecutado el tiempo de espera) y luego verifique las propiedades actualizadas. He incluido un ejemplo de código a continuación:

 setTimeout(async () => { const msg = await sent.fetch(true); console.log(msg.reactions.cache.get('👍').count); }, waitTime);
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