如何阻止管理员的消息被过滤和阻止 || Discord.js V.14

huangapple go评论129阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年2月19日 05:16:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/75496440.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定