【发布时间】:2020-11-20 18:00:55
【问题描述】:
我正在尝试构建一个函数,允许我检查我的 Discord 服务器中的所有成员,以查看他们是否处于一组特定角色中的一个,然后从他们中删除该角色。
function StripRoles(){ //will get the players who still have roles assigned to them, and remove those roles
const RolesArray = ['737531569165565982','737533396422754355','737533710798290974','737532883539066971','737533050925350932','737533864544567296','737534067188301854']; //here's the list of roles
var i;
for (i = 0; i < RolesArray.length; i++) { //loop that checks each of the roles in RolesArray
message.guild.members.cache.forEach(member => { //for each member of the server
if (member.roles.has(RolesArray[i])){ //if they have the role currently being checked
member.roles.remove(i).catch(console.error); //then remove it from them
}
})
}
}
当我运行它时,它会返回错误:
TypeError: member.roles.has is not a function
任何帮助将不胜感激!
编辑:为我自己的个人新手参考添加了更多标签
【问题讨论】:
标签: javascript discord roles