Make a command available to a certain role

Hi, I have a announce command which looks like this :

if (command === “announce”) {
let announcemessage = message.content.match(/(?<=announce ).*$/)[0];
let finalmessage = announcemessage.toUpperCase();
console.log(announcemessage);
const announceEmbed = new Discord.RichEmbed()
.setColor("#ff1233")
.setTitle(“Announcement!”)
.setDescription("" + finalmessage);
message.channel.send(announceEmbed);
message.delete().catch(O_o=>{});
}

And I was wondering how I could make this command only available to a certain role, like use a role ID to make the bot recognize that the user has that role, and if the user doesn’t have that role the bot to send a message like “You’re not Authorized” can someone help?

Welcome back to the forums!

This may help: restrict command to role discord js Code Example

You can also try to create a array of allowed ID’s.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.