Reaction Collector not getting the correct size (capped at 1)
discord.js: 14.15.3
nodejs: v18.16.0
My intents are:
Guilds
GuildMessages
GuildMessageReactions
I'm using a reaction collector. Any time I print the collected.size, it returns 1 despite the filter showing multiple users reacting.
console output when 2 users react:
it prints true twice in the filter, but the collected.size is only 1. What am I doing wrong?
If no users react, it does print zero.
please @ me if someone responds, server is on @s only10 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OP🤔
while the event emits per user,
MessageReaction
is per emoji
so since you seem to only be collecting for a single emoji, it's always going to only have one MessageReaction
you'd be looking for <MessageReaction>.users.cache.size
I see. I'm not at my computer right now, what would be the generally standard way to get the specific messagereaction I want from the collector? Would I just want to find 🔑 in collected?
well since there's only one item in the collection, you can just use
<Collection>.first()
Was going to ask about other reactions but yeah my filter does force only one reaction. What if the collection is empty?
well if there were multiple in the collection, yes it's keyed by unicode character (or id in the case of custom emojis), so you can get 🔑
if the collection is empty
first
will return undefined
alright I can just add a check for if its empty
Alright, so I'm able to collect multiple users. However, the filter isn't applied to <MessageReaction>.users so if people who got filtered out reacted it still shows up in the users I got.
I suppose you could just filter the users after the fact and only use the collector's filter for the emoji
That's what I was thinking.
This was the solution, thanks.