Ok, I know that there are similar questions out there but no matter what I try I get the same result.
(好的,我知道那里也有类似的问题,但是不管我尝试什么,我都会得到相同的结果。)
I have been trying for 2 days now to figure out how to check if I had the "OverBot-Admin" role for a ban command.(我已经尝试了2天,以弄清楚如何检查我是否具有ban命令的“ OverBot-Admin”角色。)
But whenever I run the command it spams the chat!(但是,每当我运行命令时,它就会向聊天室发送垃圾邮件!)
Here is my code:(这是我的代码:)
if (command === "ban") {
if(message.member.roles.has(role => role.name === "OverBot-Admin")) {
let reason = args.slice(1).join(" ");
if (!reason) reason = "No reason provided";
const user = message.mentions.users.first();
if (user) {
const member = message.guild.member(user);
if (member) {
member
.ban({ reason: "They were being bad." })
.then(() => {
message.reply(
":white_check_mark: Successfully banned " +
message.user.id +
"for " +
reason
);
const embed = new Discord.RichEmbed()
.setTitle("Ban")
.addField("Member:", message.user.id)
.addField("Reason:", reason)
.setTimestamp()
.setFooter(
"Created by OverThrow, OverBot SE",
"https://cdn.discordapp.com/avatars/649431468254429224/0b63291c1e7342c2320ca5c3cce806ca.png?size=2048"
);
})
.catch(err => {
message.reply(":x: I was unable to ban that member!");
console.error(err);
});
} else {
message.reply(":x: That user isn't a member to this guild!");
}
} else {
message.reply(":x: You didn't mention a member to ban!");
}
}
} else {
message.reply(":x: I couldn't ban this user, please make sure you have the OverBot-Admin role!")
}
ask by OverThrow translate from so