summaryrefslogtreecommitdiff
path: root/server/src/commands/mod/Prune.ts
diff options
context:
space:
mode:
author8cy <[email protected]>2020-07-23 23:24:17 -0700
committer8cy <[email protected]>2020-07-23 23:24:17 -0700
commitbb511abc03bb66848947e37a999502b813c77269 (patch)
tree612c010fc8317e1cdf11471a18aad0270819d33e /server/src/commands/mod/Prune.ts
parentfix: if clear amount equal or over 100, round down to 99 (diff)
downloaddep-core-bb511abc03bb66848947e37a999502b813c77269.tar.xz
dep-core-bb511abc03bb66848947e37a999502b813c77269.zip
goodbye old uwufier :cry:
Diffstat (limited to 'server/src/commands/mod/Prune.ts')
-rw-r--r--server/src/commands/mod/Prune.ts39
1 files changed, 39 insertions, 0 deletions
diff --git a/server/src/commands/mod/Prune.ts b/server/src/commands/mod/Prune.ts
new file mode 100644
index 0000000..bf56846
--- /dev/null
+++ b/server/src/commands/mod/Prune.ts
@@ -0,0 +1,39 @@
+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<Message> {
+ if (amount <= 100) amount = 99;
+ (msg.channel as TextChannel).bulkDelete(amount, true);
+ return 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 }));
+ }
+} \ No newline at end of file