[英]unban array of ids discord.js v12
Code:代码:
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);
});
}
Error:错误:
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'fetchBans' of undefined
Does anyone know what's wrong with this?有谁知道这有什么问题? The command looks like this:该命令如下所示:
-ubm <Server ID> -ubm <服务器 ID>
Note that config.ownerID
is an Array of IDs.请注意, config.ownerID
是一个 ID 数组。
There is no need to fetch
the bans of your server.无需fetch
服务器的禁令。 Simply use a message.guild.members.unban(id)
只需使用message.guild.members.unban(id)
Example:例子:
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);
}
Make sure you use semicolons where necessary - it saves irritating errors later确保在必要时使用分号——这样可以避免以后出现恼人的错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.