diff options
| author | Unknown <jtsshieh@outlook.com> | 2018-02-24 10:09:22 -0500 |
|---|---|---|
| committer | Unknown <jtsshieh@outlook.com> | 2018-02-24 10:09:22 -0500 |
| commit | abd6d61c3ce05ef2c59e14b0a3ee67d96ca777f1 (patch) | |
| tree | 67c7cbadff327e3bf21e8bf71546821bc9aba2d2 /commands/purge.js | |
| parent | b38df9dd1048f794e861531973734e64e7695c53 (diff) | |
| download | PokeBot-abd6d61c3ce05ef2c59e14b0a3ee67d96ca777f1.tar.gz PokeBot-abd6d61c3ce05ef2c59e14b0a3ee67d96ca777f1.tar.bz2 PokeBot-abd6d61c3ce05ef2c59e14b0a3ee67d96ca777f1.zip | |
Purge
Diffstat (limited to 'commands/purge.js')
| -rw-r--r-- | commands/purge.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/commands/purge.js b/commands/purge.js new file mode 100644 index 0000000..007e850 --- /dev/null +++ b/commands/purge.js @@ -0,0 +1,26 @@ +exports.run = async (bot, msg, args) => { + msg.delete(); + const user = msg.mentions.users.first(); + const amount = parseInt(args[0]) ? parseInt(args[0]) : parseInt(args[1]); + if (!amount) return msg.reply('How many message shall I delete?'); + if (!amount && !user) return msg.reply('Tell me the user and amount or the just the amount of messages to purge.'); + if (amount > 98 || amount < 2) return msg.reply('Choose an amount less than 98 and greater than 1'); + let msgs = await msg.channel.fetchMessages({ limit: amount }); + if (user) { + const filterBy = user ? user.id : bot.user.id; + msgs = msgs.filter(m => m.author.id === filterBy).array().slice(0, amount); + } + msg.channel.bulkDelete(msgs).catch(error => console.log(error.stack)); +}; + +exports.conf = { + aliases: ['prune', 'rm'], + guildOnly: true, +}; + +exports.help = { + name: 'purge', + description: 'Get rid of messages quickly.', + usage: '@(user) <messages>', + category:'Moderation', +}; |
