3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 20:35:02 +00:00

Optimizations + debug logging

This commit is contained in:
Dragory 2019-05-02 18:34:15 +03:00
parent a84fb87324
commit 6ed8aba35f
3 changed files with 16 additions and 3 deletions

View file

@ -53,6 +53,10 @@ export type UnmuteResult = {
case: Case;
};
const EXPIRED_MUTE_CHECK_INTERVAL = 60 * 1000;
let FIRST_CHECK_TIME = Date.now();
const FIRST_CHECK_INCREMENT = 5 * 1000;
export class MutesPlugin extends ZeppelinPlugin<IMutesPluginConfig> {
public static pluginName = "mutes";
@ -99,8 +103,13 @@ export class MutesPlugin extends ZeppelinPlugin<IMutesPluginConfig> {
this.serverLogs = new GuildLogs(this.guildId);
// Check for expired mutes every 5s
this.clearExpiredMutes();
this.muteClearIntervalId = setInterval(() => this.clearExpiredMutes(), 5000);
const firstCheckTime = Math.max(Date.now(), FIRST_CHECK_TIME) + FIRST_CHECK_INCREMENT;
FIRST_CHECK_TIME = firstCheckTime;
setTimeout(() => {
this.clearExpiredMutes();
this.muteClearIntervalId = setInterval(() => this.clearExpiredMutes(), EXPIRED_MUTE_CHECK_INTERVAL);
}, firstCheckTime - Date.now());
}
protected onUnload() {