禁止命令不会让我禁止其他人

时间:2020-09-16 18:13:03

标签: javascript discord discord.js bots

我的等级要比我要禁止的人高,但是错误“❌│我不能踢这个人,请检查我是否高于您要禁止的人!”如果有人可以修复和帮助我,那就太好了,谢谢!

代码-

if (
 msg.member.hasPermission('ADMINISTRATOR') ||
 msg.member.displayName === 'PixelIGPM8' ||
 msg.member.hasPermission('KICK_MEMBERS')
) {
 let member = msg.mentions.members.first();
 // prevents from not mentionning
 if (!member)
  return msg.channel.send(`?│ Imagine not mentioning someone to kick...`);
 // If the code continues, then there is a mention
 try {
  user.kick();
  msg.channel.send(`?│ Kicked! @${member.user.displayName}!`);
 } catch (err) {
  msg.channel.send(
   '❌│ I couldnt kick this person, check if im higher than the person you are trying to ban!'
  );
 }
} else msg.channel.send('❌│lol noob you dont have permission to do this.?');

2 个答案:

答案 0 :(得分:-2)

我认为您必须输入角色的ID,而不是(msg.member.hasPermission('ADMINISTRATOR')

中的名字

答案 1 :(得分:-3)

user.kick()是捕获代码的地方,因为您应该只使用member.kick(),因为它是具有kick方法的成员对象。您可以详细了解here