Added more error logging

This commit is contained in:
Erik 2024-09-30 18:46:09 +03:00
parent c037a8abe9
commit ebed2cfeb9
2 changed files with 8 additions and 12 deletions

View File

@ -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",

View File

@ -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)
{