messageReactionAdd execute isn't getting the right Client

Since I updated to 14.16 my messageReactionAdd method stopped working because of TypeError: Cannot read properties of undefined (reading 'cache') at getChannelAdmin (/home/container/helpers/helper.js:219:40) at Object.execute (/home/container/events/client/messageReactionAdd.js:42:32) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) The client class I'm getting inside my messageReactionAdd class: { burst: false } My class to get the channel: function getChannelAdmin(client) { console.info(client.channels) try { const canalAdmin = client.channels.cache.find( (channel) => channel.id === "<MY CHANNEL ID>" ); return canalAdmin; } catch (error) { console.error(error) console.info(client) }
}
No description
20 Replies
d.js toolkit
d.js toolkit7mo ago
- 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
Mark
Mark7mo ago
are you on 14.16.0 or 14.16.1? npm ls discord.js
Mark
Mark7mo ago
and how do you call the event function? fwiw, passing client is not necessary, as any d.js structure will have a client property, eg user.client etc
Titan Fury
Titan FuryOP7mo ago
No description
Titan Fury
Titan FuryOP7mo ago
btw I tested 14.16.0 and it wasn't working there too
treble/luna
treble/luna7mo ago
log client and also
d.js docs
d.js docs7mo ago
Don't use the find method to query a Collection by key (mostly the associated id)
- someCollection.find(structure => structure.id === "348607796335607817")
+ someCollection.get("348607796335607817")
- someCollection.find(structure => structure.id === "348607796335607817")
+ someCollection.get("348607796335607817")
Titan Fury
Titan FuryOP7mo ago
{ burst: false } is what I get inside my event
Titan Fury
Titan FuryOP7mo ago
and inside handleEvents class: undefined
No description
d.js docs
d.js docs7mo ago
:event: (event) Client#messageReactionAdd @14.16.1 Emitted whenever a reaction is added to a cached message.
treble/luna
treble/luna7mo ago
seems like theres 3 params also as mark mentioned, there is no need to pass in client virtually every djs structure has a client property and you wont run into issues like this
Titan Fury
Titan FuryOP7mo ago
so, what should I pass here async execute(reaction, user, client) { ?
treble/luna
treble/luna7mo ago
read
Titan Fury
Titan FuryOP7mo ago
well still, I did not get why isn't working
treble/luna
treble/luna7mo ago
because the event emits with 3 parameters now
Titan Fury
Titan FuryOP7mo ago
No description
Titan Fury
Titan FuryOP7mo ago
how should I get the client from here? this.client give the same problem as before
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Titan Fury
Titan FuryOP7mo ago
oh Now I got it xd user.client solved my problem ty for ur help and for ur patient xD I made that method 2 yrs ago so that's why it was using client as a arg

Did you find this page helpful?