import { Command } from 'discord-akairo'; import { Message } from 'discord.js'; import { TextChannel } from 'discord.js'; export default class PruneMod extends Command { public constructor() { super('prune', { aliases: ['prune', 'clear', 'purge'], category: 'moderation', description: { content: 'Bulk delete a specified amount of message from the server.', usage: '[amount]', examples: [ '50' ] }, ratelimit: 3, channel: 'guild', clientPermissions: ['MANAGE_MESSAGES'], userPermissions: ['MANAGE_MESSAGES'], args: [ { id: 'amount', type: 'integer', prompt: { start: 'How many messages would you like to delete?' } } ] }); } public exec(msg: Message, { amount }): Promise { msg.delete(); let limit = false; if (amount >= 100){ amount = 99; limit = true; } (msg.channel as TextChannel).bulkDelete(amount, true); if (limit) { msg.reply('Due to Discord API limitations, the amount of messages you have specified has been rounded down to **99**. (This message will automatically be deleted in 3 seconds.)') .then(m => m.delete({ timeout: 3000 })); } if (amount > 1) return msg.reply(`**${amount}** messages have been successfully pruned!`); else return msg.reply(`**${amount}** message has been successfully pruned!`); } }