DiscordJS V13 提及一个角色

DiscordJS V13 Mentioning a role

有人可以帮我处理这些代码吗?我想在这里发生的是,当管理员提到一个角色时,我希望它什么也不做,或者可能会发送一个回复,比如“你提到了一个角色。”

我的代码:

let findrole = args[0];
const role = message.guild.roles.cache.get.find((r) =>
  r.name.includes(findrole)
);

if (args[0] === role) return;

您可以通过检查消息中是否提到任何角色来做到这一点。您所要做的就是添加:

if (message.mentions.roles) { // This checks if a role was mentioned
    message.channel.send(`${message.mentions.roles.first().name} was mentioned`)
}