英文:
How to stop Admin's messages from getting filtered and blocked || Discord.js V.14
问题
这是我的代码:
module.exports = {
name: "messageCreate",
async execute(message) {
if (!message.guild || message.author.bot) return;
if (message.content.includes("@everyone")) {
message.delete();
message.channel.send({ content: `${message.author}, you don't have permission to tag everyone!`});
}
}
}
我希望我的机器人忽略所有包含"@everyone"文本的消息,这些消息来自启用了管理员权限的角色,并删除来自所有其他角色的消息。
英文:
This is my code:
module.exports = {
name: "messageCreate",
async execute(message) {
if (!message.guild || message.author.bot) return;
if (message.content.includes("@everyone")) {
message.delete();
message.channel.send({ content: `${message.author}, you don't have permission to tag everyone!`});
}
}
}
I want my bot to ignore all the messages with the text "@everyone" from the roles that have Administrator permission enabled and delete the messages from all the other roles.
答案1
得分: 1
删除消息的条件是,如果消息中包括@everyone 并且 成员 不是 管理员:
if (message.content.includes('@everyone') && !message.member.permissions.has(PermissionFlagBits.Administrator))
请记住,这仍可能会对所有成员产生幽灵提醒,最好通过Discord角色来抑制大规模提及。
英文:
Your condition to delete a message is if it includes @everyone and member is not an admin:
if (message.content.includes('@everyone') && !message.member.permissions.has(PermissionFlagBits.Administrator))
Keep in mind this may still produce a ghost ping for all the members, it's best to suppress mass mentioning through Discord roles
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论