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.
28 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!Whatever
guild
is defined as isnt a GuildThis is the guild.
Well IDs are strings so that already seems wrong
Should i put quotations?
Yes
@ʎǝɹquoɯ Ok that worked, but there's a different problem.
This doesn't work
That it doesn't check if it has the role
how so
Because it would respond with that the user has a transfer block
But it responded that I can't add people to the club
Should I send you the whole code, so you can review it?
I mean it looks like
member
is defined from interaction.guild
Not the guild you fetched
So yeah, never gonna have that roleYep, that's correct.
@ʎǝɹquoɯ How should i fix it?
Fetch the member for the right guild
Can you show me how the script should look like, because I'm new?
guild.members.fetch("id")
tysm
and in the id i should put the server id? @ʎǝɹquoɯ
No, the user id youre fetching
ok
is that okay?
const member = await guild.members.fetch(user.id)
yeah
Okay, I'm going to try.
@ʎǝɹquoɯ It worked, tysm!