该命令要求有一个起作用的理由,但是,即使我提到某人并给出了理由,它仍然不禁止执行。就像命令无法识别!
bot.on('message', async message => {
if (message.content == prefix + "ban") {
if (!message.member.roles.some(r => ["Administrator", "Co-owner"].includes(r.name)))
return message.reply("Sorry, you don't have permissions to use this!");
let member = message.mentions.members.first();
if (!member)
return message.reply("Please mention a valid member of this server");
if (!member.bannable)
return message.reply("I cannot ban this user! Do they have a higher role? Do I have ban permissions?");
var reason = args.slice(1).join(' ');
if (!reason) reason = "No reason provided";
await member.ban(reason);
}
});
答案 0 :(得分:0)
对于kick命令,您必须输入参数作为理由。像这样:
var reason = args.slice(1).join(' ');
member.kick(reason);
这就像第二张图片中的ban命令。
如果您需要更多帮助或说明,请问我。
如果这不起作用,请确保您的漫游器在角色层次结构中具有足够高的角色。
答案 1 :(得分:0)
终于让它起作用了!这是我的代码结尾:
bot.on('message', message => {
let member = message.mentions.members.first();
if (message.content.startsWith(prefix + "ban")) {
if (!message.member.hasPermission('BAN_MEMBERS'))
return message.reply("Sorry, you don't have permissions to use this!");
if (!member)
return message.reply("Please mention a valid member of this server");
if (!member.bannable)
return message.reply("I cannot ban this user! Do they have a higher role? Do I have ban permissions?");
// V This line has been changed V
var reason = message.content.split(' ').slice(2).join(' ');
if (!reason) return message.reply("Please specify a reason!");
member.ban(reason);
}
});
这都是因为原因!感谢所有帮助我的人,这为我打开了更多的命令之门。