mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 04:25:01 +00:00
Migrate LocateUser to new Plugin structure
This commit is contained in:
parent
4a8a63e8b8
commit
63efaf84ee
16 changed files with 380 additions and 0 deletions
60
backend/src/plugins/LocateUser/LocateUserPlugin.ts
Normal file
60
backend/src/plugins/LocateUser/LocateUserPlugin.ts
Normal file
|
@ -0,0 +1,60 @@
|
|||
import { PluginOptions } from "knub";
|
||||
import { LocateUserPluginType, ConfigSchema } from "./types";
|
||||
import { zeppelinPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { GuildVCAlerts } from "src/data/GuildVCAlerts";
|
||||
import { outdatedAlertsLoop } from "./utils/outdatedLoop";
|
||||
import { fillActiveAlertsList } from "./utils/fillAlertsList";
|
||||
import { WhereCmd } from "./commands/WhereCmd";
|
||||
import { FollowCmd } from "./commands/FollowCmd";
|
||||
import { ListFollowCmd, DeleteFollowCmd } from "./commands/ListFollowCmd";
|
||||
import { ChannelJoinEvt, ChannelSwitchEvt } from "./events/ChannelJoinEvt";
|
||||
import { ChannelLeaveEvt } from "./events/ChannelLeaveEvt";
|
||||
import { GuildBanAddEvt } from "./events/GuildBanAddEvt";
|
||||
|
||||
const defaultOptions: PluginOptions<LocateUserPluginType> = {
|
||||
config: {
|
||||
can_where: false,
|
||||
can_alert: false,
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
level: ">=50",
|
||||
config: {
|
||||
can_where: true,
|
||||
can_alert: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const LocateUserPlugin = zeppelinPlugin<LocateUserPluginType>()("locate_user", {
|
||||
configSchema: ConfigSchema,
|
||||
defaultOptions,
|
||||
|
||||
// prettier-ignore
|
||||
commands: [
|
||||
WhereCmd,
|
||||
FollowCmd,
|
||||
ListFollowCmd,
|
||||
DeleteFollowCmd,
|
||||
],
|
||||
|
||||
events: [ChannelJoinEvt, ChannelSwitchEvt, ChannelLeaveEvt, GuildBanAddEvt],
|
||||
|
||||
onLoad(pluginData) {
|
||||
const { state, guild } = pluginData;
|
||||
|
||||
state.alerts = GuildVCAlerts.getGuildInstance(guild.id);
|
||||
state.outdatedAlertsTimeout = null;
|
||||
state.usersWithAlerts = [];
|
||||
state.unloaded = false;
|
||||
|
||||
outdatedAlertsLoop(pluginData);
|
||||
fillActiveAlertsList(pluginData);
|
||||
},
|
||||
|
||||
onUnload(pluginData) {
|
||||
clearTimeout(pluginData.state.outdatedAlertsTimeout);
|
||||
pluginData.state.unloaded = true;
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue