prune debugging
This commit is contained in:
parent
617576d72e
commit
3b67b4b227
@ -40,17 +40,21 @@ class PruneInfraction extends Infraction {
|
|||||||
// +1 to so we can avoid deleting the command interaction
|
// +1 to so we can avoid deleting the command interaction
|
||||||
let messages = await this.fetchMessages(message, amount < 100 ? amount + 1 : amount); //Collection, not array.
|
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');
|
||||||
|
this.client.logger.debug(`Pruning ${messages.size} in ${this.guild.name}`);
|
||||||
|
|
||||||
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);
|
||||||
|
this.client.logger.debug(`Has old: ${hasOld}, has undeletable: ${hasUndeletable}`);
|
||||||
|
|
||||||
messages = messages.filter((m) => m.deletable && m.type !== MessageType.ChatInputCommand);
|
messages = messages.filter((m) => m.deletable && m.type !== MessageType.ChatInputCommand);
|
||||||
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);
|
||||||
|
this.client.logger.debug(`After filter: ${filtered.size}, pre filter: ${messages.size}`);
|
||||||
if (filtered.size === 0) return this._fail('C_PRUNE_NOFILTERRESULTS');
|
if (filtered.size === 0) return this._fail('C_PRUNE_NOFILTERRESULTS');
|
||||||
|
|
||||||
const deleted = await this.deleteMessages(filtered);
|
const deleted = await this.deleteMessages(filtered);
|
||||||
|
this.client.logger.debug(`Deleted ${deleted} messages`);
|
||||||
if (deleted === 0) return this._fail('C_PRUNE_NODELETE');
|
if (deleted === 0) return this._fail('C_PRUNE_NODELETE');
|
||||||
|
|
||||||
await this.handle();
|
await this.handle();
|
||||||
@ -68,7 +72,7 @@ class PruneInfraction extends Infraction {
|
|||||||
const bulkDelete = async (messages) => {
|
const bulkDelete = async (messages) => {
|
||||||
try {
|
try {
|
||||||
const deleteThese = messages.splice(0, 100);
|
const deleteThese = messages.splice(0, 100);
|
||||||
const result = await this.target.bulkDelete(deleteThese, true); //Filtering old just incase, d.js uses Snowflake times instead of our Client's timestamp.
|
const result = await this.channel.bulkDelete(deleteThese, true); //Filtering old just incase, d.js uses Snowflake times instead of our Client's timestamp.
|
||||||
if (result && result.size > 0) amount += result.size;
|
if (result && result.size > 0) amount += result.size;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.client.logger.error(error.stack);
|
this.client.logger.error(error.stack);
|
||||||
|
Loading…
Reference in New Issue
Block a user