繁体   English   中英

解禁 id 数组 discord.js v12

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM