From abd6d61c3ce05ef2c59e14b0a3ee67d96ca777f1 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 24 Feb 2018 10:09:22 -0500 Subject: Purge --- commands/ban.js | 2 +- commands/kick.js | 2 +- commands/purge.js | 26 ++++++++++++++++++++++++++ commands/softban.js | 2 +- 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 commands/purge.js (limited to 'commands') diff --git a/commands/ban.js b/commands/ban.js index 5e784e9..69a78f6 100644 --- a/commands/ban.js +++ b/commands/ban.js @@ -19,6 +19,6 @@ exports.conf = { exports.help = { name: 'ban', description: 'Ban a user from this server.', - usage: '@ <...reason>', + usage: '@ <...reason>', category: 'Moderation', }; diff --git a/commands/kick.js b/commands/kick.js index 034a003..5ed7942 100644 --- a/commands/kick.js +++ b/commands/kick.js @@ -19,6 +19,6 @@ exports.conf = { exports.help = { name: 'kick', description: 'Kick a user out of the server.', - usage: '@ <...reason>', + usage: '@ <...reason>', category: 'Moderation', }; 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) ', + category:'Moderation', +}; diff --git a/commands/softban.js b/commands/softban.js index 25abf4e..b942b3e 100644 --- a/commands/softban.js +++ b/commands/softban.js @@ -20,6 +20,6 @@ exports.conf = { exports.help = { name: 'softban', description: 'Kick the user and delete their messages.', - usage: '@ <...reason>', + usage: '@ <...reason>', category: 'Moderation', }; -- cgit v1.2.3