Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
Discord.js not properly returning the amount of a certain reactions on a message

I am currently coding a discord bot with the discord.js library. I am currently adding poll command. The user will input something that looks like this

sh.poll (Amount of time the poll will stay open for) (The contents of the poll)

All the other code works fine, it can properly read the amount of time the user inputs and can read the text the poll is suposed to show. The problem arises when the poll has to close.

The bot will start by reading the reactions that are currently on the poll, then it will output if the poll succseeded or not. However command that I am using:

Message.reactions.cache.get('Unicode Charcter').count

It always returns 1.

I feel like there is something very simple I am missing but I just cant find it.

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 Respostas
Responde à pergunta

0

Fetch the message once the poll as closed (once the timeout is executed) and then check the updated properties. I have included a code sample below:

setTimeout(async () => {

    const msg = await sent.fetch(true);
    console.log(msg.reactions.cache.get('👍').count);

}, waitTime);
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda