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

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

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