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