I made a profile command for discord. It needs to show the roles of a user. I know how to show roles of message author but the same method for showing roles of message author doesn't work for pinged members.
I'll show my code to make it more clear:
// this one works as expected message.member.roles.cache.map((role) => role.name).join(", ")
// but this one doesn't work let pingedUser = message.mentions.users.first(); pingedUser.roles.cache.map((role) => role.name).join(", ")
To fix this, you can use
message.mentions.members.first() instead as
message.mentions.members returns a
let pingedMember = message.mentions.members.first(); pingedMember.roles.cache.map((role) => role.name).join(', ');