Reputation:
How do I check if a user has a specific role? However, not by mentioning the user but through their ID. so, obviously this wouldn't work:
message.member.roles.cache.some(role => role.name === 'ROLE')
neither does client.users.cache.get('ID');
have a property allowing me to access their roles. neither does client.users.fetch
. So how can I do it?
Upvotes: 1
Views: 3035
Reputation: 9041
client.users.fetch()
and client.users.cache.get()
both return User
s which don't have roles. You need to get a GuildMember
from a guild
let member = guild.members.cache.get("id")
let hasRole = member.roles.cache.some(role => role.name === 'ROLE')
Upvotes: 1