【发布时间】:2020-09-02 19:26:47
【问题描述】:
1 天前,我为一个不和谐的机器人发布了一个问题,说我的 id 不是 null 的属性。现在它的作品。但它仍然无法禁止,它给了我代码上标记的错误:message.reply("I was unable to ban the member :(");
这是代码:
const Discord = require('discord.js');
const client = new Discord.Client();
module.exports = {
name: 'ban',
description: "ban peoples ;D",
execute(message, args, client) {
if (!message.member.hasPermission("BAN_MEMBERS") ||
!message.member.hasPermission("ADMINISTRATOR")) return message.channel.send("You don't have a permissions to do this, maybe later ;) ");
const user = message.mentions.users.first();
const member = message.guild.member(user);
if (!user) return message.channel.send("Please mention the user to make this action");
if (user.id === message.author.id) return message.channel.send("You can't ban yourself, I tried :(");
member.ban(() => {
message.channel.send('Successfully banned **${user.tag}**');
}).catch(err => {
message.reply("I was unable to ban the member :(");
})
}
}
我检查了机器人是否需要权限,我给了他,但它仍然无法正常工作。
【问题讨论】:
-
在您的 catch 块中,写上
console.log(err)以更好地诊断问题。 -
at ``` }).catch(err => {``` ?
-
是的。
catch(err => { console.log(err)
标签: javascript visual-studio discord.js