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() {
|
async execute() {
|
||||||
|
|
||||||
const { amount, message } = this.data;
|
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');
|
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 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);
|
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');
|
if (messages.size === 0) return this._fail('C_PRUNE_NOTDELETABLE');
|
||||||
|
|
||||||
const filtered = await this.filterMessages(messages);
|
const filtered = await this.filterMessages(messages);
|
||||||
|
@ -164,18 +164,14 @@ class CommandHandler extends Observer {
|
|||||||
|
|
||||||
if (response instanceof Message) return;
|
if (response instanceof Message) return;
|
||||||
|
|
||||||
try { // Temporary -- trying to figure out why the bot sometimes errors with unknown interaction
|
if (response) {
|
||||||
if (response) {
|
if (response instanceof MessageEmbed) return invoker.reply({ embeds: [response] });
|
||||||
if (response instanceof MessageEmbed) return invoker.reply({ embeds: [response] });
|
else if (typeof response === 'string') return invoker.reply({ content: response });
|
||||||
else if (typeof response === 'string') return invoker.reply({ content: response });
|
else if (typeof response === 'object') return invoker.reply(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 (!invoker.replied) return invoker.reply({ index: 'O_COMMANDHANDLER_COMMAND_NORESPONSE', ephemeral: !invoker.replied });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async _parseInteraction(interaction, command) {
|
async _parseInteraction(interaction, command) {
|
||||||
|
Loading…
Reference in New Issue
Block a user