diff --git a/src/structure/DiscordClient.js b/src/structure/DiscordClient.js index 16b517c..eea4dec 100644 --- a/src/structure/DiscordClient.js +++ b/src/structure/DiscordClient.js @@ -278,6 +278,10 @@ class DiscordClient extends Client { return this.storageManager.mongodb; } + get moderation() { + return this.moderationManager; + } + } // module.exports = DiscordClient; diff --git a/src/structure/client/ModerationManager.js b/src/structure/client/ModerationManager.js index faa7567..66b4660 100644 --- a/src/structure/client/ModerationManager.js +++ b/src/structure/client/ModerationManager.js @@ -419,13 +419,14 @@ class ModerationManager { } //TODO: Log this, should never error... hopefully. - await this.client.storageManager.mongodb.infractions.updateOne( - { id: i.id }, - { _callbacked: true } - ).catch((e) => { - this.logger.error(`Error during update of infraction:\n${e.stack || e}`); - }); - this.callbacks.delete(i.id); + // await this.client.storageManager.mongodb.infractions.updateOne( + // { id: i.id }, + // { _callbacked: true } + // ).catch((e) => { + // this.logger.error(`Error during update of infraction:\n${e.stack || e}`); + // }); + // this.callbacks.delete(i.id); + await this.removeCallback(this.callbacks.get(i.id), true); return true; @@ -451,13 +452,15 @@ class ModerationManager { } - async removeCallback(callback) { + async removeCallback(callback, updateCase = false) { this.logger.debug(`Removing callback ${callback.infraction.type} for user ${callback.infraction.target}.`); - // await this.client.storageManager.mongodb.infractions.updateOne( - // { id: expiration.infraction.id }, - // { _callbacked: true } - // ).catch((e) => { }); //eslint-disable-line no-empty, no-unused-vars, no-empty-function - clearTimeout(callback.timeout); //just incase node.js is doing some bullshit + if(updateCase) await this.client.storageManager.mongodb.infractions.updateOne( + { id: callback.infraction.id }, + { _callbacked: true } + ).catch((e) => { + this.logger.error(`Error during update of infraction:\n${e.stack || e}`); + }); + clearTimeout(callback.timeout); this.callbacks.delete(callback.infraction.id); }