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

124
Views
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 answers
Answer question

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