Reputation: 339
I am working on a mute command and got this error
TypeError: Cannot read property 'add' of undefined
This is my code
const person = message.mentions.users.first()
person.roles.add(muterole.id)
I have tried: person.addRole but it also doesnt work and person.roles.add(muterole) but it also doesnt work
Any Idea why? thanks
Upvotes: 2
Views: 77
Reputation: 3005
You have to use message.mentions.members.first()
. A User
doesn't have any role, because it represents a user on Discord, and a Member
has roles, it represents a User
in a Guild
(another answer).
const person = message.mentions.members.first()
person.roles.add(muterole.id)
Upvotes: 2