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