forked from Galactic/galactic-bot
tweak to prune
This commit is contained in:
parent
dc176fca50
commit
f48ba2ea61
@ -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);
|
||||
|
@ -164,7 +164,6 @@ 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 });
|
||||
@ -172,9 +171,6 @@ class CommandHandler extends Observer {
|
||||
}
|
||||
|
||||
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}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user