简体   繁体   English

您如何迭代/获取用户的角色 ID?

[英]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.我想遍历单个用户的整个角色 ID 列表,并查看该用户是否具有我拥有的文件中的角色 ID 之一。 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.就在“AccessListR.includes()”处,我不知道该放什么,因为用户角色 ID 列表应该是 go 或类似的东西。 I think I need a function to iterate through them and return them each time to the if statement.我想我需要一个 function 来遍历它们并每次将它们返回给 if 语句。 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:您可以使用Collection.some()检查角色之一是否返回 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.")
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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