简体   繁体   中英

How do you iterate/get ever role ID from a user?

I want to iterate through the entire list of role IDs from a single user and see if that user has one of the role IDs on a file I have. Right at "AccessListR.includes()" is where I don't know what to put because that's where the list of user role IDs should go or something like that. I think I need a function to iterate through them and return them each time to the if statement. Except... I don't know how to access the list of roles from a user. Here's my code:

if ((AccessListBot.includes(message.author.username) || AccessListBotR.includes()) && message.content.includes(prefix)){
message.channel.send("ERROR: You have been blacklisted from using this bot.")

}

You can use Collection.some() to check if one of the role returns true:

if ((AccessListBot.includes(message.author.username) || (message.member.roles.cache.some((role) => AccessListBotR.includes(role.id))) && message.content.includes(prefix)){
message.channel.send("ERROR: You have been blacklisted from using this bot.")
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM