本文介紹了無法讀取未定義的屬性“fetchBans"的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我正在嘗試一個新命令,即 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)
這篇關(guān)于無法讀取未定義的屬性“fetchBans"的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!