From bd2c52cb2bfccc94396a0ec02a50fc63ee545622 Mon Sep 17 00:00:00 2001 From: nolan Date: Mon, 21 Jun 2021 14:20:05 -0700 Subject: [PATCH] Don't infinitely attempt to resolve a deleted channel/missing user --- structure/moderation/ModerationManager.js | 31 +++++++++++------------ 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/structure/moderation/ModerationManager.js b/structure/moderation/ModerationManager.js index bc2cd12..a81687e 100644 --- a/structure/moderation/ModerationManager.js +++ b/structure/moderation/ModerationManager.js @@ -356,23 +356,22 @@ class ModerationManager { target = guild.channels.resolve(i.target); } - if(!target) { - this.client.logger.debug(`User left the guild or channel was deleted? Unable to resolve target.\n${i}`); - return false; + if(target) { + const executor = guild.members.resolve(i.executor) || guild.me; + + await new undoClass(this.client, { + type: undoClass.type, + reason: `AUTO-${Constant.Opposites[i.type]} from Case ${i.case}`, + channel: guild.channels.resolve(i.channel), + hyperlink: i.modLogMessage && i.modLogChannel ? `https://discord.com/channels/${i.guild}/${i.modLogChannel}/${i.modLogMessage}` : null, + data: i.data, + guild, + target, + executor + }).execute(); + } else { + //Target left guild or channel was removed from the guild. What should happen in this situation? } - - const executor = guild.members.resolve(i.executor) || guild.me; - - await new undoClass(this.client, { - type: undoClass.type, - reason: `AUTO-${Constant.Opposites[i.type]} from Case ${i.case}`, - channel: guild.channels.resolve(i.channel), - hyperlink: i.modLogMessage && i.modLogChannel ? `https://discord.com/channels/${i.guild}/${i.modLogChannel}/${i.modLogMessage}` : null, - data: i.data, - guild, - target, - executor - }).execute(); //TODO: Log this, should never error... hopefully. await this.client.storageManager.mongodb.infractions.updateOne(