Remove first check delay for expired mute checking
This commit is contained in:
parent
c806e8415a
commit
d54f03361a
1 changed files with 5 additions and 13 deletions
|
@ -59,8 +59,6 @@ const defaultOptions = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const EXPIRED_MUTE_CHECK_INTERVAL = 60 * 1000;
|
const EXPIRED_MUTE_CHECK_INTERVAL = 60 * 1000;
|
||||||
let FIRST_CHECK_TIME = Date.now();
|
|
||||||
const FIRST_CHECK_INCREMENT = 5 * 1000;
|
|
||||||
|
|
||||||
export const MutesPlugin = zeppelinGuildPlugin<MutesPluginType>()({
|
export const MutesPlugin = zeppelinGuildPlugin<MutesPluginType>()({
|
||||||
name: "mutes",
|
name: "mutes",
|
||||||
|
@ -115,17 +113,11 @@ export const MutesPlugin = zeppelinGuildPlugin<MutesPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
afterLoad(pluginData) {
|
afterLoad(pluginData) {
|
||||||
// Check for expired mutes every 5s
|
clearExpiredMutes(pluginData);
|
||||||
const firstCheckTime = Math.max(Date.now(), FIRST_CHECK_TIME) + FIRST_CHECK_INCREMENT;
|
pluginData.state.muteClearIntervalId = setInterval(
|
||||||
FIRST_CHECK_TIME = firstCheckTime;
|
() => clearExpiredMutes(pluginData),
|
||||||
|
EXPIRED_MUTE_CHECK_INTERVAL,
|
||||||
setTimeout(() => {
|
);
|
||||||
clearExpiredMutes(pluginData);
|
|
||||||
pluginData.state.muteClearIntervalId = setInterval(
|
|
||||||
() => clearExpiredMutes(pluginData),
|
|
||||||
EXPIRED_MUTE_CHECK_INTERVAL,
|
|
||||||
);
|
|
||||||
}, firstCheckTime - Date.now());
|
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeUnload(pluginData) {
|
beforeUnload(pluginData) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue