[英]unban array of ids discord.js v12
代碼:
if (command === "ubm") {
console.log(chalk.yellow`You ran a command: ubm`);
const guild = client.guilds.cache.get(args[0]);
const me = config.ownerID;
await guild.fetchBans(me).then((g) => {
g.members.unban(me);
});
}
錯誤:
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'fetchBans' of undefined
有誰知道這有什么問題? 該命令如下所示:
-ubm <服務器 ID>
請注意, config.ownerID
是一個 ID 數組。
無需fetch
服務器的禁令。 只需使用message.guild.members.unban(id)
例子:
if(command === "ubm"){
console.log((chalk.yellow)`You ran a command: ubm`);
const guild = client.guilds.cache.get(args[0]); //I would suggest adding some error trapping here, as if the guild doesnt exist the bot will throw
const me = config.ownerID[0]; //get necessary element in array
message.guild.members.unban(me);
}
確保在必要時使用分號——這樣可以避免以后出現惱人的錯誤
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.