0

Okay, I remember I did this before but, I quite can't remember what the code was.

I want the bot to check if the command's author has the role "Delete Masters". If not then it should give out the error "You don't have the required role!".

This is the code I currently have:

const amount = parseInt(args[2]) + 1;
if (isNaN(amount)) {
    return msg.reply("that doesnt seem to be a valid number.");
} else if (amount <= 1 || amount > 100) {
    return msg.reply("you need to input a number between 2 and 100.");
}
msg.channel.bulkDelete(amount, true).catch((err) => {
    console.error(err);
    msg.channel.send("there was an error trying to delete messages in this channel!");
});       
Jakye
  • 6,440
  • 3
  • 19
  • 38

1 Answers1

0

You can use message.member.roles.cache.has() (Assuming you're using DJS v12) to check if the member has the role. Pass in the Delete Master Role ID into .has()

Here's an example

if (message.member.roles.cache.has('1234567890') {
   // Allow message deletion
} else {
   // Error message
}

Elitezen
  • 6,551
  • 6
  • 15
  • 29