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

107
Vistas
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 Respuestas
Responde la pregunta

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