3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-08 03:27:20 +00:00

Centralize periodic checks for mutes, tempbans, vcalerts, reminders, and scheduled posts

This should result in a significant performance improvement.
The new method is also more precise than the old one, allowing
the aforementioned checks to be performed with second-precision.
This commit is contained in:
Dragory 2021-09-25 21:33:59 +03:00
parent c84d1a0be1
commit c7751a9da1
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
55 changed files with 883 additions and 366 deletions

View file

@ -6,7 +6,8 @@ import { RemindCmd } from "./commands/RemindCmd";
import { RemindersCmd } from "./commands/RemindersCmd";
import { RemindersDeleteCmd } from "./commands/RemindersDeleteCmd";
import { ConfigSchema, RemindersPluginType } from "./types";
import { postDueRemindersLoop } from "./utils/postDueRemindersLoop";
import { onGuildEvent } from "../../data/GuildEvents";
import { postReminder } from "./functions/postReminder";
const defaultOptions: PluginOptions<RemindersPluginType> = {
config: {
@ -46,16 +47,16 @@ export const RemindersPlugin = zeppelinGuildPlugin<RemindersPluginType>()({
state.reminders = GuildReminders.getGuildInstance(guild.id);
state.tries = new Map();
state.unloaded = false;
state.postRemindersTimeout = null;
},
afterLoad(pluginData) {
postDueRemindersLoop(pluginData);
pluginData.state.unregisterGuildEventListener = onGuildEvent(pluginData.guild.id, "reminder", (reminder) =>
postReminder(pluginData, reminder),
);
},
beforeUnload(pluginData) {
clearTimeout(pluginData.state.postRemindersTimeout);
pluginData.state.unregisterGuildEventListener();
pluginData.state.unloaded = true;
},
});