add role
hi so ive been trying a lot to make this work but it just wont
im updating my code from v12.3.1 to 14.13.0 and im trying to update this code but there are 3 errors
first one, on the first // there is an error with the 'has'
second one, on the second //there is an error with 'highest'
and finally, on user.roles.add(role) there is always the error 'cannot read properties of undefined reading 'add''
and all of the console.log give me a real role and a real member, also im testing on a test server so i have perms, the bot has perms, the user is below the bot, the role is below the bot role
idk what to do
11 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!users dont have roles, members do
let user = message.mentions.users.first() client.users.cache.get(args[0]) client.users.cache.find(user => user.username === nombrea)
should i just change that to member?
yes
and fetch instead of using cache
you'd have to refactor to <Guild>.members
i simplified the code by not using the cache and switched user to member and still got the same errors
errors here
// if (user.roles.cache.has(role.id)) return message.channel.send("reply")
// if (message.member.roles.highest.comparePositionTo(user.roles.highest) <= 0) return message.channel.send("reply")
and if i delete them there is still the error cannot read properties of add
and it seemed weird to just switch user to member as in console.log(user/member) is the same thing
you did not change it
you just renamed your variable
that wont magically change its type
wdym change it?
let member = message.mentions.users.first()
what else could it be?
and it gives me a member objet on the console
thats not a member is it?
thanks
!