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