can't set role to user (user.roles.add is not a function)
If I have a code like this
It doesn't work and it shows that
add()
is not a member of roles
And these are all the functions that are listed for roles
And that should be the correct way to set a role to a member according to the discord.js guide
https://discordjs.guide/popular-topics/faq.html#how-do-i-add-a-role-to-a-guild-member
instead I get this error:
discord.js: v14.16.3
deno: v2.0.3discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
10 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 OPlog user, and consider properly naming your variables, a user isnt a member
I understand, It was just an example.
Ok, I noticed that it returns
False
when interaction.inCachedGuild()
is called, and from what I understand it needs to be cached for it to work correctly.
How can this be achieved?By having the Guilds intent
it should be like this right? that's my current setup
Is your app a user installed app? If not, is it added with the bot scope
it's not a user installed app, and sorry where to check if it's added to the bot scope or not?
When you added the bot to your server
Oh ok, Thanks that fixed it, forgot to add it in the dev portal