Advertisement
Ryyan

Untitled

Jul 3rd, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. if (command === "purge") {
  2. // This command removes all messages from all users in the channel, up to 100.
  3.  
  4. // get the delete count, as an actual number.
  5. const deleteCount = parseInt(args[0], 10);
  6.  
  7. // Ooooh nice, combined conditions. <3
  8. if (!deleteCount || deleteCount < 2 || deleteCount > 100)
  9. return message.reply("Please provide a number between 2 and 100 for the number of messages to delete");
  10.  
  11. // So we get our messages, and delete them. Simple enough, right?
  12. const fetched = await message.channel.fetchMessages({
  13. limit: deleteCount
  14. });
  15. message.channel.bulkDelete(fetched)
  16. .catch(error => message.reply(`Couldn't delete messages because of: ${error}`));
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement