Remove first check delay for expired mute checking

This commit is contained in:
Dragory 2021-08-19 22:12:39 +03:00
parent c806e8415a
commit d54f03361a
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -59,8 +59,6 @@ const defaultOptions = {
};
const EXPIRED_MUTE_CHECK_INTERVAL = 60 * 1000;
let FIRST_CHECK_TIME = Date.now();
const FIRST_CHECK_INCREMENT = 5 * 1000;
export const MutesPlugin = zeppelinGuildPlugin<MutesPluginType>()({
name: "mutes",
@ -115,17 +113,11 @@ export const MutesPlugin = zeppelinGuildPlugin<MutesPluginType>()({
},
afterLoad(pluginData) {
// Check for expired mutes every 5s
const firstCheckTime = Math.max(Date.now(), FIRST_CHECK_TIME) + FIRST_CHECK_INCREMENT;
FIRST_CHECK_TIME = firstCheckTime;
setTimeout(() => {
clearExpiredMutes(pluginData);
pluginData.state.muteClearIntervalId = setInterval(
() => clearExpiredMutes(pluginData),
EXPIRED_MUTE_CHECK_INTERVAL,
);
}, firstCheckTime - Date.now());
clearExpiredMutes(pluginData);
pluginData.state.muteClearIntervalId = setInterval(
() => clearExpiredMutes(pluginData),
EXPIRED_MUTE_CHECK_INTERVAL,
);
},
beforeUnload(pluginData) {