Advertisement
Ryyan

Untitled

Jul 20th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. if(command === "purge") {
  2. let embed = new Discord.RichEmbed()
  3. .setColor("#ff0000")
  4. .setTitle(`❌${message.author.username}, error!❌`)
  5. .setDescription(`Invaild permissions.\n permissions needed: "MANAGE_ROLES", "ADMINISTRATOR"`)
  6. .setTimestamp()
  7.  
  8. if (!message.member.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send(embed)
  9. // This command removes all messages from all users in the channel, up to 100.
  10.  
  11. // get the delete count, as an actual number.
  12. const deleteCount = parseInt(args[0], 10);
  13.  
  14. // Ooooh nice, combined conditions. <3
  15. if(!deleteCount || deleteCount < 2 || deleteCount > 100)
  16. return message.reply("Please provide a number between 2 and 100 for the number of messages to delete");
  17.  
  18. // So we get our messages, and delete them. Simple enough, right?
  19. const fetched = await message.channel.fetchMessages({limit: deleteCount});
  20. message.channel.bulkDelete(fetched)
  21. .catch(error => message.reply(`Couldn't delete messages because of: ${error}`));
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement