Cannot read properties of undefined (reading 'cache')

Hey, I got another problem. Cannot read properties of undefined (reading 'cache'). I want it to find a role in a different server (where the bot is). I would appreciate help.
No description
28 Replies
d.js toolkit
d.js toolkit6mo 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!
monbrey
monbrey6mo ago
Whatever guild is defined as isnt a Guild
officialdatch
officialdatch6mo ago
No description
officialdatch
officialdatch6mo ago
This is the guild.
monbrey
monbrey6mo ago
Well IDs are strings so that already seems wrong
officialdatch
officialdatch6mo ago
Should i put quotations?
monbrey
monbrey6mo ago
Yes
officialdatch
officialdatch6mo ago
@ʎǝɹquoɯ Ok that worked, but there's a different problem.
officialdatch
officialdatch6mo ago
This doesn't work
No description
officialdatch
officialdatch6mo ago
That it doesn't check if it has the role
monbrey
monbrey6mo ago
how so
officialdatch
officialdatch6mo ago
Because it would respond with that the user has a transfer block
officialdatch
officialdatch6mo ago
No description
officialdatch
officialdatch6mo ago
But it responded that I can't add people to the club Should I send you the whole code, so you can review it?
monbrey
monbrey6mo ago
I mean it looks like member is defined from interaction.guild Not the guild you fetched So yeah, never gonna have that role
officialdatch
officialdatch6mo ago
Yep, that's correct.
officialdatch
officialdatch6mo ago
No description
officialdatch
officialdatch6mo ago
@ʎǝɹquoɯ How should i fix it?
monbrey
monbrey6mo ago
Fetch the member for the right guild
officialdatch
officialdatch6mo ago
Can you show me how the script should look like, because I'm new?
monbrey
monbrey6mo ago
guild.members.fetch("id")
officialdatch
officialdatch6mo ago
tysm and in the id i should put the server id? @ʎǝɹquoɯ
monbrey
monbrey6mo ago
No, the user id youre fetching
officialdatch
officialdatch6mo ago
ok
officialdatch
officialdatch6mo ago
is that okay?
No description
officialdatch
officialdatch6mo ago
const member = await guild.members.fetch(user.id)
monbrey
monbrey6mo ago
yeah
officialdatch
officialdatch6mo ago
Okay, I'm going to try. @ʎǝɹquoɯ It worked, tysm!
Want results from more Discord servers?
Add your server