diff --git a/src/client/components/managers/ModerationManager.ts b/src/client/components/managers/ModerationManager.ts index bb1f12a..533a936 100644 --- a/src/client/components/managers/ModerationManager.ts +++ b/src/client/components/managers/ModerationManager.ts @@ -204,7 +204,7 @@ class ModerationManager implements Initialisable, CallbackClient const results = await this.#client.mongodb.infractions.find(filter); this.#logger.info(`Filtering ${results.length} infractions for callback.`); for (const result of results) - this.handleTimedInfraction(result); + await this.handleTimedInfraction(result); const ids = results.map(result => result._id); await this.#client.mongodb.infractions.removeProperty({ _id: { $in: ids } }, [ '_callbacked' ]); this.#ready = true; @@ -754,7 +754,9 @@ class ModerationManager implements Initialisable, CallbackClient async findActiveInfraction (type: InfractionType, target: string, guild: string) { const [ callback ] = await this.#client.callbacks.queryCallbacks({ type, target, guild }, this); - return callback ?? null; + if (!callback) + return null; + return callback; } async findActiveInfractions (query: Partial) diff --git a/src/client/components/observers/UtilityHook.ts b/src/client/components/observers/UtilityHook.ts index cff1bec..01022e9 100644 --- a/src/client/components/observers/UtilityHook.ts +++ b/src/client/components/observers/UtilityHook.ts @@ -71,7 +71,7 @@ class UtilityHook extends Observer // }); const callback = await this.client.moderation.findActiveInfraction('MUTE', member.id, guild.id); - const infraction = callback.payload; + const infraction = callback?.payload; if (!infraction || infraction.resolved) return; diff --git a/src/middleware/Controller.ts b/src/middleware/Controller.ts index 20faef0..9828da4 100644 --- a/src/middleware/Controller.ts +++ b/src/middleware/Controller.ts @@ -86,6 +86,7 @@ class Controller extends EventEmitter // this.#shardingManager.on('message', this._handleMessage.bind(this)); process.on('SIGINT', this.shutdown.bind(this)); + process.on('SIGTERM', this.shutdown.bind(this)); } async build ()