踢命令不起作用并在尝试踢管理员时出错,我该如何解决?

时间:2021-04-28 12:41:41

标签: javascript discord discord.js

我在我的机器人中添加了审核命令,但我不希望人们能够踢管理员,所以我添加了一些代码,但效果不佳,当我执行 ,kick 时它告诉我请指定一个成员踢,完美,当我执行 ,kick @[user] 时它踢用户,但是当我尝试踢管理员时,它给我一条错误消息说 Cannot read property 'has' of undefined 这里是代码

module.exports = {
    name: 'kick',
    description: '[DESCRIPTION]',
    async execute(Client, message, args, Discord) {
        const member = message.mentions.users.first();
        if(message.member.permissions.has("ADMINISTRATOR") || message.member.permissions.has("KICK_MEMBERS") || Client.users.cache.find(u => u.tag === 'Mr Tophat#3864').id){
            if(!member){
                message.channel.send("Please specify a member to kick");
            }
            else if(member.permissions.has("ADMINISTRATOR")){
                message.channel.send("You can't an admin");
            }
            else{
                if(member){
                    const memberTarget = message.guild.members.cache.get(member.id);
                    memberTarget.kick();
                    message.channel.send("User has been kicked!");
                }
            }
        }
    }
}

1 个答案:

答案 0 :(得分:2)

您收到此错误是因为您试图访问 import pandas as pd cluster_global = 0 cluster_relativo = 0 cluster_index = [] for index, row in df.iterrows(): if row['cluster'] == cluster_relativo: cluster_index.append(cluster_global) elif row['cluster'] == (cluster_relativo + 1): cluster_global += 1 cluster_relativo += 1 cluster_index.append(cluster_global) elif row['cluster'] == 0: cluster_global += 1 cluster_relativo = 0 cluster_index.append(cluster_global) permissions 而不是 user。像这样声明您的 guildMember

member

区别在于,const member = message.mentions.members.first(); 全局不和谐useruser 是特定{{1}上的guildMember }}


参考