Migrate Reminders to new Plugin structure
This commit is contained in:
parent
b6257b9189
commit
7ce1ebfee2
7 changed files with 247 additions and 0 deletions
50
backend/src/plugins/Reminders/RemindersPlugin.ts
Normal file
50
backend/src/plugins/Reminders/RemindersPlugin.ts
Normal file
|
@ -0,0 +1,50 @@
|
|||
import { PluginOptions } from "knub";
|
||||
import { ConfigSchema, RemindersPluginType } from "./types";
|
||||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { GuildReminders } from "src/data/GuildReminders";
|
||||
import { postDueRemindersLoop } from "./utils/postDueRemindersLoop";
|
||||
import { RemindCmd } from "./commands/RemindCmd";
|
||||
import { RemindersCmd } from "./commands/RemindersCmd";
|
||||
import { RemindersDeleteCmd } from "./commands/RemindersDeleteCmd";
|
||||
|
||||
const defaultOptions: PluginOptions<RemindersPluginType> = {
|
||||
config: {
|
||||
can_use: false,
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
level: ">=50",
|
||||
config: {
|
||||
can_use: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const RemindersPlugin = zeppelinPlugin<RemindersPluginType>()("reminders", {
|
||||
configSchema: ConfigSchema,
|
||||
defaultOptions,
|
||||
|
||||
// prettier-ignore
|
||||
commands: [
|
||||
RemindCmd,
|
||||
RemindersCmd,
|
||||
RemindersDeleteCmd,
|
||||
],
|
||||
|
||||
onLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
|
||||
state.reminders = GuildReminders.getGuildInstance(guild.id);
|
||||
state.tries = new Map();
|
||||
state.unloaded = false;
|
||||
|
||||
state.postRemindersTimeout = null;
|
||||
postDueRemindersLoop(pluginData);
|
||||
},
|
||||
|
||||
onUnload(pluginData) {
|
||||
clearTimeout(pluginData.state.postRemindersTimeout);
|
||||
pluginData.state.unloaded = true;
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue