From 7c5f6ec97f732fc79b5fa49307fcb7a840b1ea4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bersier?= Date: Thu, 6 Sep 2018 18:42:40 +0200 Subject: [PATCH] disalbe purge --- commands/purge | 23 ++++++++--------------- commands/purge.js | 15 --------------- 2 files changed, 8 insertions(+), 30 deletions(-) delete mode 100644 commands/purge.js diff --git a/commands/purge b/commands/purge index 16f84f93..a17831c1 100644 --- a/commands/purge +++ b/commands/purge @@ -1,22 +1,15 @@ exports.run = (client, message, args) => { - - const StaffRole = message.guild.roles.find("name", "Staff"); - if (!StaffRole) - return console.log("The Staff role does not exist"); - - if (!message.member.roles.has(StaffRole.id)) - return message.reply("Sick you thought"); - - if (!message.GuildMember.hasPermission()) - return message.reply(" "); - + const user = message.mentions.users.first(); const amount = !!parseInt(message.content.split(' ')[1]) ? parseInt(message.content.split(' ')[1]) : parseInt(message.content.split(' ')[2]) if (!amount) return message.reply('Must specify an amount to delete!'); + if (!amount && !user) return message.reply('Must specify a user and amount, or just an amount, of messages to purge!'); message.channel.fetchMessages({ limit: 100, }).then((messages) => { - messages = messages.filter(m => m.author.id).array().slice(0, amount); - + if (user) { + const filterBy = user ? user.id : Client.user.id; + messages = messages.filter(m => m.author.id === filterBy).array().slice(0, amount); + } message.channel.bulkDelete(messages).catch(error => console.log(error.stack)); - }) -} \ No newline at end of file + }); +}; \ No newline at end of file diff --git a/commands/purge.js b/commands/purge.js deleted file mode 100644 index a17831c1..00000000 --- a/commands/purge.js +++ /dev/null @@ -1,15 +0,0 @@ -exports.run = (client, message, args) => { - const user = message.mentions.users.first(); - const amount = !!parseInt(message.content.split(' ')[1]) ? parseInt(message.content.split(' ')[1]) : parseInt(message.content.split(' ')[2]) - if (!amount) return message.reply('Must specify an amount to delete!'); - if (!amount && !user) return message.reply('Must specify a user and amount, or just an amount, of messages to purge!'); - message.channel.fetchMessages({ - limit: 100, - }).then((messages) => { - if (user) { - const filterBy = user ? user.id : Client.user.id; - messages = messages.filter(m => m.author.id === filterBy).array().slice(0, amount); - } - message.channel.bulkDelete(messages).catch(error => console.log(error.stack)); - }); -}; \ No newline at end of file