From ebed2cfeb91cf449a036e741ba444416c901798a Mon Sep 17 00:00:00 2001 From: Navy Date: Mon, 30 Sep 2024 18:46:09 +0300 Subject: [PATCH] Added more error logging --- .eslintrc.json | 4 +++- .../components/managers/ModerationManager.ts | 16 +++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 79d5190..af5e324 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -27,7 +27,9 @@ "@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/no-non-null-assertion": "off", "@typescript-eslint/no-misused-promises": ["error", { - // "checksVoidReturn": false + "checksVoidReturn": { + "arguments": false + } }], "accessor-pairs": "warn", "array-callback-return": "warn", diff --git a/src/client/components/managers/ModerationManager.ts b/src/client/components/managers/ModerationManager.ts index 3d0a4a0..964981b 100644 --- a/src/client/components/managers/ModerationManager.ts +++ b/src/client/components/managers/ModerationManager.ts @@ -170,8 +170,7 @@ class ModerationManager implements Initialisable, CallbackClient constructor (client: DiscordClient) { this.#client = client; - // this.#callbacks = new Collection(); - this.#logger = client.createLogger(this); // new Logger({ name: 'ModMngr' }); + this.#logger = client.createLogger(this); this.#infractionClasses = Constant.Infractions; this.#ready = false; } @@ -418,11 +417,6 @@ class ModerationManager implements Initialisable, CallbackClient /** * - * @param {class} Infraction - * @param {User | GuildMember} target - * @param {object} info - * @return {Infraction} - * @memberof ModerationManager */ // eslint-disable-next-line max-lines-per-function async _handleTarget ( @@ -431,7 +425,6 @@ class ModerationManager implements Initialisable, CallbackClient info: HandleTargetData ) { - // wrapper: guildWrapper const { reason, force, guild } = info; const { automod, modpoints } = await guild.settings(); const { Type: type } = Infraction; @@ -609,13 +602,12 @@ class ModerationManager implements Initialisable, CallbackClient async handleCallback (_id: string, infraction: InfractionJSON) { - // const infraction = await this.#client.mongodb.infractions.findOne({ id }); if (!infraction) return; this.#logger.debug(`Infraction callback: ${infraction.id} (${infraction.type})`); const undoClass = Constant.Infractions[Constants.InfractionOpposites[infraction.type]]; if (!undoClass) - return; + return this.#logger.error(`Missing undo class for ${infraction.type}`); const guild = await this.#client.getGuildWrapper(infraction.guild!); if (!guild) @@ -646,7 +638,7 @@ class ModerationManager implements Initialisable, CallbackClient throw new Error('Missing executor'); try { - await new undoClass(this.#client, this.#logger, { + const result = await new undoClass(this.#client, this.#logger, { type: undoClass.Type, reason: `AUTO-${Constants.InfractionOpposites[infraction.type]} from Case ${infraction.case}`, channel, @@ -657,6 +649,8 @@ class ModerationManager implements Initialisable, CallbackClient target, executor }).execute(); + if (result.error) + this.#logger.error(result); } catch (err) {