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)
}
}
}

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 OPare you on 14.16.0 or 14.16.1?
npm ls discord.js
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
btw I tested 14.16.0 and it wasn't working there too
log client
and also
{ burst: false }
is what I get inside my event
and inside handleEvents class: undefined

:event: (event) Client#messageReactionAdd
@14.16.1
Emitted whenever a reaction is added to a cached message.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
so, what should I pass here async execute(reaction, user, client) { ?
read
well still, I did not get why isn't working
because the event emits with 3 parameters now

how should I get the client from here?
this.client give the same problem as before
Unknown User•7mo ago
Message Not Public
Sign In & Join Server To View
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