diff options
| author | 8cy <[email protected]> | 2020-07-23 23:24:17 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-07-23 23:24:17 -0700 |
| commit | bb511abc03bb66848947e37a999502b813c77269 (patch) | |
| tree | 612c010fc8317e1cdf11471a18aad0270819d33e /src/commands/moderation/clear.ts | |
| parent | fix: if clear amount equal or over 100, round down to 99 (diff) | |
| download | dep-core-bb511abc03bb66848947e37a999502b813c77269.tar.xz dep-core-bb511abc03bb66848947e37a999502b813c77269.zip | |
goodbye old uwufier :cry:
Diffstat (limited to 'src/commands/moderation/clear.ts')
| -rw-r--r-- | src/commands/moderation/clear.ts | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/src/commands/moderation/clear.ts b/src/commands/moderation/clear.ts deleted file mode 100644 index c162ac4..0000000 --- a/src/commands/moderation/clear.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { Command, CommandoMessage, CommandoClient } from 'discord.js-commando'; -//@ts-ignore no types -import emoji from 'emoji-random'; - -module.exports = class ClearModeration extends Command { - constructor(client: CommandoClient) { - super(client, { - name: 'clear', - aliases: ['delete', 'del', 'c'], - group: 'moderation', - memberName: 'clear', - description: 'Clears a specified amount of messages.', - guildOnly: true, - args: [ - { - key: 'deleteAmount', - prompt: 'How many messages would you like to delete?', - type: 'integer' - } - ], - examples: [ - 'uwu!clear 23', - 'uwu!delete 75', - 'uwu!del 32', - 'uwu!c 45', - 'uwu!d 84' - ], - throttling: { - usages: 5, - duration: 30 - }, - userPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY', 'MANAGE_MESSAGES'], - clientPermissions: ['SEND_MESSAGES', 'READ_MESSAGE_HISTORY', 'MANAGE_MESSAGES'] - }); - } - //@ts-ignore this is not promise based - async run(msg: CommandoMessage, { deleteAmount }: any) { - if (deleteAmount >= 100) { - deleteAmount == 100; - msg.author.send(`Due to Discord API limitations, your request has been rounded down to **100**. ${emoji.random()}`) - } - if (msg.member.hasPermission('MANAGE_MESSAGES')) { - if (!deleteAmount) { - return msg.reply('You haven\'t specified an amount of messages which should be deleted. ' + emoji.random()).then(deleteNotificationMessage => { - //@ts-ignore this exists - deleteNotificationMessage.delete({ timeout: 2000 }); - //@ts-ignore this exists - msg.delete({ timeout: 2000 }) - }); - } else if (isNaN(deleteAmount)) { - return msg.reply('The amount parameter isn\'t a number. ' + emoji.random()).then(deleteNotificationMessage => { - //@ts-ignore this exists - deleteNotificationMessage.delete({ timeout: 2000 }); - //@ts-ignore this exists - msg.delete({ timeout: 2000 }) - }); - } else if (deleteAmount > 100) { - return msg.reply('You can\'t delete more than 100 messages at once. ' + emoji.random()).then(deleteNotificationMessage => { - //@ts-ignore this exists - deleteNotificationMessage.delete({ timeout: 2000 }); - //@ts-ignore this exists - msg.delete({ timeout: 2000 }) - }); - } else if (deleteAmount < 1) { - return msg.reply('You have to delete at least 1 message. ' + emoji.random()).then(deleteNotificationMessage => { - //@ts-ignore this exists - deleteNotificationMessage.delete({ timeout: 2000 }); - //@ts-ignore this exists - msg.delete({ timeout: 2000 }) - }); - } - /*else if (msg.createdTimestamp > 1209600) { - msg.reply('due to discord rules, bots can only bulk delete messages that are under 14 days old :(') - } */ - else { - var clearAmount = deleteAmount + 1; - // It took me so long to figure out why this was not really working. It would delete but an insane amount at a time. - // I realized that because it was getting parsed as a string, it would just add 1 to it so if I tried to delete 1 - // message, it would delete 11 lol. Fixed by parsing as integer THEN adding one. 02:30 2020/04/03/2020 - - await msg.channel.messages.fetch({ - limit: clearAmount - }).then(messages => { // I am on v11 discord.js - // why the hell did i put this msg here lol, its 07:56 on 2020/04/27 and i woke up at 6am and i dont really know - // why i put this msg here lol, i am on v12 so that msg mustve been a while ago lol - //@ts-ignore this exists - msg.channel.bulkDelete(messages); - }); - return msg.reply('It\'s been deleted ~uwu ' + emoji.random()).then(deleteNotificationMessage => { - //@ts-ignore this exists - deleteNotificationMessage.delete({ timeout: 2000 }); - //@ts-ignore this exists - msg.delete({ timeout: 2000 }) - }); - } - } else { - return msg.reply('Insufficent permsissions. ' + emoji.random()); - } - } -};
\ No newline at end of file |