Fetch all reactions from a message but without cache
Hey there, is that a way to fetch all reactions attached to a message without using the cache function?
This is my current code
I looked for examples online and read through the documentation but I only found the "cache" function.
8 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 staffwithout cache, do you mean without iterating over each of the individual reactions?
No, I mean that I got the count wrong... e.g a message have 87 reactions but with that code above I just got 61
I’m using a variable to simply add the emoji count on each iteration and then console.log that variable to check the results
Up! Is there no way to achieve this, right? I couldn't find a get or fetch command that is not using the cache.
i'm not sure what you are hoping to achieve here
to explain this from the api
- you request the message data, which includes reactions for each emoji
- per emoji you can then request the users that reacted with that emoji
in discord.js that means, when fetching the message, we create a reaction manager for it, which holds methods for removal adding, etc. for which the data is in the
.cache
each of those reaction structures will hold a user manager at .users
which you can then fetch the users from that reacted with that specific emoji
the managers here are the layer of wrapper abstraction we apply to be somewhat in line with object oriented programming principles vs. the raw REST route approach which the discord docs explain (just routes that return data - which you should cache so you don't make unnecessary requests (which is exactly what we do with the library))you need to explain like this everytime 😭 so good
Thanks for the explanation. This help request comes from another thing that I asked here: https://discord.com/channels/222078108977594368/1295427588843372678
The issue I have right now is that when I export all the posts in a forum, the reaction numbers are not updated/synced with what is on the server.
That looks exactly like what I need. Can you link to the documentation on both things (force fetch and update cache with reaction intents)?
:method: Message#fetch()
@14.16.3
Fetch this message.
:dtypes: v10: GatewayIntentBits - GuildMessageReactions
read moreThanks! I added the reaction intents and everything seems to work as expected now