我正在制作一個(gè)不和諧的機(jī)器人,我主要學(xué)習(xí)了 discord.js 的 v11,當(dāng)我在不和諧中創(chuàng)建一個(gè) unban 命令時(shí),當(dāng)我完成時(shí),我運(yùn)行了該命令,它給出了錯(cuò)誤“TypeError:無法讀取屬性” hasPermission' of undefined",這是我的代碼。順便說一句,它是一個(gè)命令處理程序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.
TypeError:無法讀取未定義的屬性“hasPermission”
縹緲止盈
2022-10-08 17:14:37