This commit is contained in:
Erik 2022-05-01 20:24:43 +03:00
parent a3de76c8bd
commit 5839d1c25d
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
2 changed files with 20 additions and 13 deletions

View File

@ -278,6 +278,10 @@ class DiscordClient extends Client {
return this.storageManager.mongodb;
}
get moderation() {
return this.moderationManager;
}
}
// module.exports = DiscordClient;

View File

@ -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);
}