我正在尝试一个新命令,即 unban
命令.但是,如果我运行下面的代码,我会不断收到 Cannot read property 'fetchBans' of undefined
.我目前使用的是 v12.16.3.
I'm trying out a new command, which is the unban
command. However, if I run the code below I keep getting Cannot read property 'fetchBans' of undefined
. I'm currently using v12.16.3.
if(!message.member.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) 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 = await client.guild.fetchBans(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", "ADMINISTRATOR"])) return message.channel.send("I dont have permission to perform this command!")|
message.delete()
try {
message.guild.guild.fetchBans(bannedMember, reason)
message.channel.send(`${bannedMember.tag} has been unbanned from the guild!`)
} catch(e) {
console.log(e.message)
}
let embed = new Discord.MessageEmbed()
.setColor('RANDOM')
.setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL)
.addField("Moderation:", "unban")
.addField("Moderated on:", `${bannedMember.username} (${bannedMember.id})`)
.addField("Moderator:", message.author.username)
.addField("Reason:", reason)
let sChannel = message.guild.channels.find(c => c.name === "modlog")
sChannel.send(embed)
message.guild.guild
不存在,删除第二个guild
:
message.guild.fetchBans(bannedMember, reason)
这篇关于无法读取未定义的属性“fetchBans"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!