【问题标题】:I want to check if someone has permission to be kicked, but the answer is wrong我想检查是否有人有被踢的权限,但答案是错误的
【发布时间】:2021-09-11 22:52:12
【问题描述】:

我使用msg.member.hasPermission('KICK_MEMBERS'),但是即使邮件作者没有这个权限,答案也是true而不是false

const Discord = require("discord.js");
const client = new Discord.Client();
channel = '858963360909099068';

module.exports ={
    name: 'kick',
    description: 'kick people',
    execute(msg, args) {

        let impostor = msg.mentions.members.first();
        const mod = msg.author;
        let botResponse;  

        if(msg.member.hasPermission('KICK_MEMBERS')){
            console.log('true');
            if(!impostor){
                botResponse = 'You need to tag the person that you want to kick !';
                impostor = 'Not specified';
            }
            else{
                botResponse = `${impostor} was kicked !`;
                impostor.kick();
            }
        }
        else{
            console.log('false');
            botResponse = 'You are not able to kick people !';
        }
        
        let embed = new Discord.MessageEmbed()
        .setColor('#f9ae0e')
        .setTitle('Kick')
        .setDescription(botResponse)
        .addFields(
            { name: "Impostor", value: impostor},
            { name: "Member", value: mod}
        );

        msg.channel.send(embed);
}
}

这是错误:

TypeError: msg.member.hasPermission is not a function

我看不出这里有什么问题,你能帮我解决吗?

【问题讨论】:

  • 好吧。我解决问题。 @everyone 角色拥有管理员权限。

标签: discord discord.js bots


【解决方案1】:

您应该将msg.member.hasPermission('PERM') 更改为msg.member.permissions.has('PERM')

【讨论】:

  • 我试过这个。同样的问题。好像它跳过了这个如果,但我不知道为什么......还有其他建议吗?
猜你喜欢
  • 2021-03-02
  • 1970-01-01
  • 1970-01-01
  • 2021-12-30
  • 2016-09-12
  • 1970-01-01
  • 2021-04-24
  • 2018-12-20
  • 1970-01-01
相关资源
最近更新 更多