Check if user a role id from array

Hey there, so what I am trying to do is have an array:
const allowed = [
'role1',
'role2'
]
const allowed = [
'role1',
'role2'
]
And I am trying to check if a user has at least one of these roles on their profile. I have if(!allowed.includes()), but I don't know where to go from there. If anyone can help, that would be great, thanks!
3 Replies
d.js docs
d.js docs2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
istay
istay2y ago
Could it be something like this? if(!message.member.roles.hasAny(allowedRoles)) return;
Squid
Squid2y ago
hasAny is the right way to go, but it takes rest params instead of an array, so you have to do .hasAny(...allowedRoles)