不和谐的js“ .kickable”功能不适用于我的代码

时间:2020-09-25 12:36:24

标签: javascript discord.js

我正在尝试为审核机器人编写一个kick命令,但是我有一个小问题,每当我尝试踢一个角色的权限低于该机器人时,该机器人仍然说不能即使该成员的角色位于漫游器的下方,也可以踢该成员。它会与其他成员产生相同的错误。我检查了终端中的错误,但没有出现错误。

Here is the error message I get from the bot.

代码错误:

if(!target.kickable) return message.channel.send(targetUnkickable)

整个代码:

const Discord = require('discord.js')

module.exports.run = async (bot, message, args) => {

//Embeds

const noPermission = new Discord.MessageEmbed()
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setDescription('No Permission!')
.setColor("FF0000")

const kickingSelf = new Discord.MessageEmbed()
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setDescription('You can\'t kick yourself!')
.setColor("FF0000")

const kickingOwner = new Discord.MessageEmbed()
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setDescription('You can\'t kick the owner!')
.setColor("FF0000")

const noTarget = new Discord.MessageEmbed()
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setDescription('You didn\'t specify a user VIA mention or id.')
.setColor("FF0000")

const botnoPermission = new Discord.MessageEmbed()
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setDescription('I don\'t have permission to do this!')
.setColor("FF0000")

const targetUnkickable = new Discord.MessageEmbed()
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setDescription('I can\'t kick this target!')
.setColor("FF0000")

const userkickingMe = new Discord.MessageEmbed()
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setDescription('You can\'t kick me with my own command!')
.setColor("FF0000")

//Optional

let target = message.mentions.users.first() || message.guild.members.cache.get(args[0])
let reason = args.slice(1).join(' ')

if(!message.member.hasPermission("KICK_MEMBERS")) return message.channel.send(noPermission)
if(!target) return message.channel.send(noTarget)
if(target.id === message.author.id) return message.channel.send(kickingSelf)
if(target.id === message.guild.owner.id) return message.channel.send(kickingOwner)
if(target.id === '757929955429711954') return message.channel.send(userkickingMe)
//error here
if(!target.kickable) return message.channel.send(targetUnkickable)

if(!message.guild.me.hasPermission("KICK_MEMBERS")) return message.channel.send(botnoPermission)
if(!reason) reason = 'Unspecified'

if(target){
    //Rest of code goes here
   }
}


    module.exports.help = {
    name: 'kick',
    aliases: ["kick"]
}

0 个答案:

没有答案