它不会禁止我提到的人。我的代码:
const Discord = require('discord.js')
const fs = require('fs');
//Ban.js
module.exports = {
name: "ban",
description: "This command ban's someone",
category: "moderation",
example: ["!ban @member"],
callback: async ({ message, args }) => {
try {
const member = message.mentions.members.first();
const permission = message.member.permissions.has(Discord.Permissions.FLAGS.BAN_MEMBERS)
if (!permission)
return message.reply({
contents: ":failed:1050462335556386846> | You don't have permission to use this command"
});
if (!args[0]) return message.reply({ content: `:failed:1050462335556386846> | Please specify someone` });
if (!member) return message.reply({ content: `💤 | Cannot find that member...` } );
if (member.id === message.author.id)
return message.reply({ content: `:failed:1050462335556386846> | You cannot ban yourself!` });
if (message.member.roles.highest.position < member.roles.highest.position)
return message.reply({
content: `:failed:1050462335556386846> | You cannot ban user who have higher role than you...`
});
if (!member.bannable) return message.reply({ content: `:failed:1050462335556386846> | I cannot ban that member `});
return (
(await member.ban()) +
message
.reply({
content: `:anger: | User ${member} has been banned`
})
.then((msg) => {
setTimeout(() => msg.delete(), 5000);
})
);
} catch(err) {
message.reply({ content: `:failed:1050462335556386846> There was an ${err}` })
}
}, };
不应该使用command.execute(message, args)
来执行命令,而应该使用command.callback({ message, args })
。这就是为什么它不起作用,你的核心功能没有执行。