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 toolkit8mo 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
monbrey8mo ago
Whatever guild is defined as isnt a Guild
officialdatch
officialdatchOP8mo ago
No description
officialdatch
officialdatchOP8mo ago
This is the guild.
monbrey
monbrey8mo ago
Well IDs are strings so that already seems wrong
officialdatch
officialdatchOP8mo ago
Should i put quotations?
monbrey
monbrey8mo ago
Yes
officialdatch
officialdatchOP8mo ago
@ʎǝɹquoɯ Ok that worked, but there's a different problem.
officialdatch
officialdatchOP8mo ago
This doesn't work
No description
officialdatch
officialdatchOP8mo ago
That it doesn't check if it has the role
monbrey
monbrey8mo ago
how so
officialdatch
officialdatchOP8mo ago
Because it would respond with that the user has a transfer block
officialdatch
officialdatchOP8mo ago
No description
officialdatch
officialdatchOP8mo 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
monbrey8mo 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
officialdatchOP8mo ago
Yep, that's correct.
officialdatch
officialdatchOP8mo ago
No description
officialdatch
officialdatchOP8mo ago
@ʎǝɹquoɯ How should i fix it?
monbrey
monbrey8mo ago
Fetch the member for the right guild
officialdatch
officialdatchOP8mo ago
Can you show me how the script should look like, because I'm new?
monbrey
monbrey8mo ago
guild.members.fetch("id")
officialdatch
officialdatchOP8mo ago
tysm and in the id i should put the server id? @ʎǝɹquoɯ
monbrey
monbrey8mo ago
No, the user id youre fetching
officialdatch
officialdatchOP8mo ago
ok
officialdatch
officialdatchOP8mo ago
is that okay?
No description
officialdatch
officialdatchOP8mo ago
const member = await guild.members.fetch(user.id)
monbrey
monbrey8mo ago
yeah
officialdatch
officialdatchOP8mo ago
Okay, I'm going to try. @ʎǝɹquoɯ It worked, tysm!
Want results from more Discord servers?
Add your server