forked from Supositware/Haha-Yes
This commit is contained in:
parent
da238ee58d
commit
b6cc76e282
1 changed files with 15 additions and 0 deletions
15
commands/purge.js
Normal file
15
commands/purge.js
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
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));
|
||||||
|
});
|
||||||
|
};
|
Loading…
Reference in a new issue