我正在尝试获得一个禁令命令,并且我使用我之前的 kick 命令作为一种模板,我无法完全理解禁令的原因,我假设这是代码下面的唯一问题。
const Discord = require('discord.js')
module.exports.run = async (bot, message, args) => {
if (!message.member.hasPermission('BAN_MEMBERS')) return message.reply('**No permission**')
const user = message.mentions.users.first();
if (user) {
const member = message.guild.member(user);
if (member) {
member
.ban('no reason')
.then(() => {
message.channel.send(`${user.tag} Has been banned`)
})
.catch(err => {
message.reply('Unable');
console.error(err);
});
} else {
message.reply("Error");
}
} else {
message.reply("You forgot to mention someone");
}
};
module.exports.help = {
name: "ban"
}
答案 0 :(得分:1)
您必须为 .ban()
在这种情况下.ban({reason: 'no reason'})
所以你更正的代码是
if (!message.member.hasPermission("BAN_MEMBERS"))
return message.reply("**No permission**");
const user = message.mentions.users.first();
if (user) {
const member = message.guild.member(user);
if (member) {
member
.ban({ reason: "no reason" })
.then(() => {
message.channel.send(`${user.tag} Has been banned`);
})
.catch((err) => {
message.reply("Unable");
console.error(err);
});
} else {
message.reply("Error");
}
} else {
message.reply("You forgot to mention someone");
}
另外,请在以后提供错误并预先查找 Other information。