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

112
Visualizações
This reaction collection filter is always returning 1

I made a method for client. It is supposed to calculate how many reactions there are for 2 different emojis, and return the difference.

client.calcscore = async function(m) {
    //m is an instance of Message
    if(m.partial) await m.fetch()
    let upvotes = m.reactions.cache.filter(r => r.emoji.name === '⬆️').size;
    let downvotes = m.reactions.cache.filter(r => r.emoji.name === '⬇️').size
    return upvotes - downvotes
}

The "score" is kind of like Stack Overflow's score. However upvotes always returns 1 and downvotes always returns 1. This means the function always returns 0. This is called in a reaction event, and I know I am reacting:

I reacted

Does it have something to do with caching? I await fetching the reaction and message in the event, and then pass it in. I even tried getting my second bot to react, and it still got 1.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use r.count in your filter to get an int of how many people have given a reaction. Use that number to measure your scores.

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