Haha-Yes/commands/admin/prune.js

28 lines
990 B
JavaScript
Raw Normal View History

2018-09-07 23:57:33 +02:00
const { Command } = require('discord.js-commando');
module.exports = class PruneCommand extends Command {
constructor(client) {
super(client, {
name: 'prune',
2018-09-08 02:25:58 +02:00
aliases: ['purge'],
2018-09-08 16:13:47 +02:00
group: 'admin',
2018-09-07 23:57:33 +02:00
memberName: 'prune',
2018-09-08 16:13:47 +02:00
description: 'Bulk delete messages.',
2018-09-07 23:57:33 +02:00
clientPermissions: ['MANAGE_MESSAGES'],
userPermissions: ['MANAGE_MESSAGES'],
});
}
2018-09-09 21:40:45 +02:00
async run(message, args) {
const amount = parseInt(args[0]) + 1;
if (isNaN(amount)) {
return message.reply('that dosen\'t seem to be a valid number.');
2018-09-07 23:57:33 +02:00
}
2018-09-09 21:40:45 +02:00
else if (amount <= 1 || amount > 100) {
return message.reply('you need to input a number between 1 and 99.');
}
message.channel.bulkDelete(amount, true).catch(err => {
console.error(err);
message.channel.send('there was an error trying to prune messages in this channel!');
});
}}