From f48ba2ea610eab30c47dcb96bd9ffa3f3ffa99ff Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Mon, 18 Jul 2022 11:23:53 +0300 Subject: [PATCH] tweak to prune --- src/structure/components/infractions/Prune.js | 5 +++-- .../components/observers/CommandHandler.js | 16 ++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/structure/components/infractions/Prune.js b/src/structure/components/infractions/Prune.js index d64f406..de9f9ab 100644 --- a/src/structure/components/infractions/Prune.js +++ b/src/structure/components/infractions/Prune.js @@ -36,13 +36,14 @@ class PruneInfraction extends Infraction { async execute() { const { amount, message } = this.data; - let messages = await this.fetchMessages(message, amount); //Collection, not array. + // +1 to so we can avoid deleting the command interaction + let messages = await this.fetchMessages(message, amount < 100 ? amount + 1 : amount); //Collection, not array. if (messages.size === 0) return this._fail('C_PRUNE_NOTFETCHED'); const hasOld = messages.some((m) => m.createdTimestamp >= Date.now() + 1209600000); //I hope Node.js can handle these large of numbers.. e_e (2 weeks) const hasUndeletable = messages.some((m) => m.deletable); - messages = messages.filter((m) => m.deletable); + messages = messages.filter((m) => m.deletable && m.type !== 'APPLICATION_COMMAND'); if (messages.size === 0) return this._fail('C_PRUNE_NOTDELETABLE'); const filtered = await this.filterMessages(messages); diff --git a/src/structure/components/observers/CommandHandler.js b/src/structure/components/observers/CommandHandler.js index ea7310b..2cef7ba 100644 --- a/src/structure/components/observers/CommandHandler.js +++ b/src/structure/components/observers/CommandHandler.js @@ -164,18 +164,14 @@ class CommandHandler extends Observer { if (response instanceof Message) return; - try { // Temporary -- trying to figure out why the bot sometimes errors with unknown interaction - if (response) { - if (response instanceof MessageEmbed) return invoker.reply({ embeds: [response] }); - else if (typeof response === 'string') return invoker.reply({ content: response }); - else if (typeof response === 'object') return invoker.reply(response); - } - - if (!invoker.replied) return invoker.reply({ index: 'O_COMMANDHANDLER_COMMAND_NORESPONSE', ephemeral: !invoker.replied }); - } catch (err) { - this.logger.error(`Error responding to ${invoker.command.name}:\n${err.stack}`); + if (response) { + if (response instanceof MessageEmbed) return invoker.reply({ embeds: [response] }); + else if (typeof response === 'string') return invoker.reply({ content: response }); + else if (typeof response === 'object') return invoker.reply(response); } + if (!invoker.replied) return invoker.reply({ index: 'O_COMMANDHANDLER_COMMAND_NORESPONSE', ephemeral: !invoker.replied }); + } async _parseInteraction(interaction, command) {