TypeError:无法读取未定义的属性'hasPermission'

问题描述 投票:0回答:1

我正在制造一个discord机器人,我学到的主要是discord.js的v11版本,当我在discord中创建unban命令时,然后当我完成后,我运行了该命令,它给出了错误“ TypeError:无法读取属性“ hasPermission”未定义”,这是我的代码。 顺便说一下它的命令处理程序

module.exports = {
    name : 'unban',
    execute(client, message, args){
       if(!message.member.hasPermission(["BAN_MEMBERS"])) return message.channel.send("You dont have permission to perform this command!")
    if(isNaN(args[0])) return message.channel.send("You need to provide an ID.")
    let bannedMember =  client.users.fetch(args[0])
        if(!bannedMember) return message.channel.send("Please provide a user id to unban someone!")

    let reason = args.slice(1).join(" ")
        if(!reason) reason = "No reason given!"

    if(!message.guild.me.hasPermission(["BAN_MEMBERS"])) return message.channel.send("I dont have permission to perform this command!")|
    message.delete()
    try {
        message.guild.members.unban(bannedMember, reason)
        message.channel.send(`**${bannedMember.tag}** has been unbanned from the guild!`)
    } catch(e) {
        console.log(e.message)
    }
}




No idea what the problem is.
javascript command discord.js
1个回答
0
投票

看起来message.guild.me.hasPermissionmessage.member.hasPermission都是有效方法。您确定已定义message变量吗?检查您的命令处理程序。

© www.soinside.com 2019 - 2024. All rights reserved.