'DiscordJS V13 Mentioning a role
Can someone help me with these code? What I want to happen here is when an admin mentions a role, I want it to do nothing or maybe send a reply like "You mentioned a role."
My Code:
let findrole = args[0];
const role = message.guild.roles.cache.get.find((r) =>
r.name.includes(findrole)
);
if (args[0] === role) return;
Solution 1:[1]
You can do that by checking if there are any roles mentioned in the message. All you have to do is add:
if (message.mentions.roles) { // This checks if a role was mentioned
message.channel.send(`${message.mentions.roles.first().name} was mentioned`)
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Caladan |