好的,我一直在制作简单的机器人命令,并为我的不和谐机器人提出了!demote
命令的想法。
我试图将找到的角色从r.id更改为r.name,但仍然无法正常工作。还尝试了一些其他的东西。 这是我编写的代码:
case 'demote':
var embedDemote = new Discord.RichEmbed()
.setColor(0x19d400)
.setTitle(' :white_check_mark: SUCCESSFULLY DEMOTED :white_check_mark: ')
.addField('Demoted by:', message.author.username, true)
var embedDfail = new Discord.RichEmbed()
.setColor(0xc20404)
.setTitle(':writing_hand: DEMOTION FAILED :writing_hand: ')
.addField('THIS PERSON IS NOT STAFF!', ':heavy_multiplication_x: ')
var mentioneds = message.mentions.members.first();
if (!message.member.hasPermission('MANAGE_MESSAGES') && !message.member.hasPermission('BAN_MEMBERS') && !message.member.hasPermission('KICK_MEMBERS')) return message.channel.send(':x: You do not have a permission to do use this command :x:');
else if (!message.mentions.roles.find(r => r.name === 'Staff Team')) return message.channel.sendEmbed(embedDfail);
else {
mentioneds.removeRole('620039041538064406');
mentioneds.removeRole('620038986143891466');
mentioneds.removeRole('620039104113147934');
mentioneds.removeRole('615576343492427781');
message.channel.sendEmbed(embedDemote);
}
break;
我无法发布整个代码,因为switch命令从上面开始100 ish行。但是我希望机器人首先检查命令用户是否具有使用该命令的权限,如果真机器人应该检查所提到的人是否具有称为Staff Team的角色,如果是,则机器人应删除Head Mod,Mod,T-Mod和Staff Team提到的用户的角色。 但是,它只是说该成员不拥有职员团队角色,即使该成员确实拥有。权限检查代码可以正常工作,但角色名称根本不起作用。无论我收到什么消息,表示该成员缺少职员团队角色。
任何帮助都是有用的,感谢您阅读此问题。