Trying to pull users who reacted to a specified message with a specified emoji, need some guidance
Here's my code, can't seem to get reactedUsers to populate with the right values. This makes it a map with 0 length. Is there anything obvious I'm missing here?
20 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 staffsorry, [email protected]
node 17.5.0
💩
It is the Unicode character in the code, but discord translated it to
:poop:
when I pasted it into Discord for the help ticket
for instance, this doesn't work either:
Fixed that issue, now running into a new one with reactedUsers
being undefined
you aren't returning a value in the filter function
it's always the dumbest mistakes huh
Sorry, from what I can tell the filter function doesn’t require a return value, just as the native JS array.filter doesn’t require one (docs say they’re near identical but that collection.filter returns a collection rather than an array).
They require a return value :thonk:
a boolean to be precise, to know what passes the filter and what doesnt
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter#callbackfn
Okay, my bad
Okay, that worked. Now reactedUsers is a Map with size 0, even though the message being pulled has 2 💩 reactions on it.
is this the problem?
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
no you should not do that
you can just fetch the reaction and that should contain the users, hopefully
How would I fetch the reaction?
add a .fetch() to it
I'm not 100% certain if that fetches the users though
still a map with size 0
let reactedUsers = await reactions.get(emojiOption).fetch();
ahh okay
let reactedUsers = await reactions.get(emojiOption).users.fetch();
empty maptwo reactions, one from myself and one from my friend
the message id there is definitely correct
sure one sec
how would i do that? here's emojiOption
i've just never seen that format before, apologies
one sec
okay this is working
keys and emoji came out to 💩
now winner is undefined but that's not djs, just js, i can get that fixed
thank you all!