Pulling reactions not working when the message has a button attached

Hello when I run this code I get Collection(0) [Map] {} giving me no reactions to loop through. But when I try the same code on another message that does not have a button on it, I get this: Collection(1) [Map] { with my beloved reactions inside of it.
const message = await client.channels.cache.get(`977096542462808115`).messages.fetch(`1132567332921823323`)

console.log(message.reactions.cache)
const reaction = await message.reactions.cache.first();
const users = await reaction.users.fetch();
const message = await client.channels.cache.get(`977096542462808115`).messages.fetch(`1132567332921823323`)

console.log(message.reactions.cache)
const reaction = await message.reactions.cache.first();
const users = await reaction.users.fetch();
how can I fix this? @.gwapes
43 Replies
d.js toolkit
d.js toolkit11mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Post the full error stack trace, not just the top part! - Show your code! - Explain what exactly your issue is. - Not a discord.js issue? Check out #useful-servers. - Issue solved? Press the button!
zackie
zackie11mo ago
Here is an image example of what I am looking at
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
zackie
zackie11mo ago
I assumed so sorry
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
zackie
zackie11mo ago
this is my log when I do it on the message in the image above Collection(0) [Map] {} It gives me what I want
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
zackie
zackie11mo ago
yea im real stumped tried googling and chatgpt
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
zackie
zackie11mo ago
yeah its really specific was there also an embed in that message?
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
zackie
zackie11mo ago
yeah definitely
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
zackie
zackie11mo ago
const reaction = await message.reactions.cache.first(); ^ TypeError: Cannot read properties of undefined (reading 'cache')
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
zackie
zackie11mo ago
var testchannel = await client.channels.cache.get(`977096542462808115`)
const message = await testchannel.messages.fetch(`1132567332921823323`)
const reaction = await message.reactions.cache.first();

console.log(message.reactions.cache)

const users = await reaction.users.fetch();
var testchannel = await client.channels.cache.get(`977096542462808115`)
const message = await testchannel.messages.fetch(`1132567332921823323`)
const reaction = await message.reactions.cache.first();

console.log(message.reactions.cache)

const users = await reaction.users.fetch();
message.reactions.cache = Collection(0) [Map] {} error: const users = await reaction.users.fetch(); ^ TypeError: Cannot read properties of undefined (reading 'users') exact same code on a different message with reactions works like a charm
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
zackie
zackie11mo ago
module.exports = {

loopReacts: async function(interaction, client) {
module.exports = {

loopReacts: async function(interaction, client) {
pass it through a function
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
zackie
zackie11mo ago
Here's the whole code, a lot of it won't be relevant
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
zackie
zackie11mo ago
It just doesnt seem to be caching the reactions when I apply the same code to another message it seems to be caching it message.reactions has: reactions: [Circular *1], then message.reactions.cache = Collection(0) [Map] {}
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
zackie
zackie11mo ago
its so weird, because what runs this code is a button, and I want that button to be on the same message that the reactions will be on, but if I make two seperates messages containing this button and I press the older one, but still using the code to pull reacts from the newer message it will work, but doing the same thing with the new message I get no reactions cached
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
zackie
zackie11mo ago
zackie
zackie11mo ago
zackie
zackie11mo ago
I got these two messages, and when I reload the bot and press the top one first it works fine and then also press the bottom after that and it works fine
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
zackie
zackie11mo ago
(the code is coded to get reactions from the bottom message no matter what button I press) have tried same result
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
zackie
zackie11mo ago
IntentsBitField { bitfield: 38659 }
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
zackie
zackie11mo ago
I might shoot myself discord is trolling me
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
zackie
zackie11mo ago
its gaslighting me by workign sometimes and then not working the next
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
zackie
zackie11mo ago
this worked like a charm before I tried it with the buttons idk wtf like how does it work when I press the above button but not the one below same code
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
zackie
zackie11mo ago
Oh my god My heroes
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
zackie
zackie11mo ago
No both I will forever be in your debt
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View