mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-25 18:25:03 +00:00
uniform before/after Load shorthands
Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
parent
933635fcd0
commit
33c6ae2188
26 changed files with 218 additions and 169 deletions
|
@ -2,7 +2,7 @@ import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
|
||||||
export const TRIGGER_COMPARISON_OPS = ["=", "!=", ">", "<", ">=", "<="] as const;
|
export const TRIGGER_COMPARISON_OPS = ["=", "!=", ">", "<", ">=", "<="] as const;
|
||||||
|
|
||||||
export type TriggerComparisonOp = (typeof TRIGGER_COMPARISON_OPS)[number];
|
export type TriggerComparisonOp = typeof TRIGGER_COMPARISON_OPS[number];
|
||||||
|
|
||||||
const REVERSE_OPS: Record<TriggerComparisonOp, TriggerComparisonOp> = {
|
const REVERSE_OPS: Record<TriggerComparisonOp, TriggerComparisonOp> = {
|
||||||
"=": "!=",
|
"=": "!=",
|
||||||
|
|
|
@ -56,9 +56,11 @@ export const AutoDeletePlugin = zeppelinGuildPlugin<AutoDeletePluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeUnload(pluginData) {
|
beforeUnload(pluginData) {
|
||||||
pluginData.state.guildSavedMessages.events.off("create", pluginData.state.onMessageCreateFn);
|
const { state, guild } = pluginData;
|
||||||
pluginData.state.guildSavedMessages.events.off("delete", pluginData.state.onMessageDeleteFn);
|
|
||||||
pluginData.state.guildSavedMessages.events.off("deleteBulk", pluginData.state.onMessageDeleteBulkFn);
|
state.guildSavedMessages.events.off("create", state.onMessageCreateFn);
|
||||||
|
state.guildSavedMessages.events.off("delete", state.onMessageDeleteFn);
|
||||||
|
state.guildSavedMessages.events.off("deleteBulk", state.onMessageDeleteBulkFn);
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||||
|
|
|
@ -53,9 +53,11 @@ export const AutoReactionsPlugin = zeppelinGuildPlugin<AutoReactionsPluginType>(
|
||||||
],
|
],
|
||||||
|
|
||||||
beforeLoad(pluginData) {
|
beforeLoad(pluginData) {
|
||||||
pluginData.state.savedMessages = GuildSavedMessages.getGuildInstance(pluginData.guild.id);
|
const { state, guild } = pluginData;
|
||||||
pluginData.state.autoReactions = GuildAutoReactions.getGuildInstance(pluginData.guild.id);
|
|
||||||
pluginData.state.cache = new Map();
|
state.savedMessages = GuildSavedMessages.getGuildInstance(guild.id);
|
||||||
|
state.autoReactions = GuildAutoReactions.getGuildInstance(guild.id);
|
||||||
|
state.cache = new Map();
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||||
|
|
|
@ -222,137 +222,129 @@ export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()({
|
||||||
messageCommands: [AntiraidClearCmd, SetAntiraidCmd, ViewAntiraidCmd],
|
messageCommands: [AntiraidClearCmd, SetAntiraidCmd, ViewAntiraidCmd],
|
||||||
|
|
||||||
async beforeLoad(pluginData) {
|
async beforeLoad(pluginData) {
|
||||||
pluginData.state.queue = new Queue();
|
const { state, guild } = pluginData;
|
||||||
|
|
||||||
pluginData.state.regexRunner = getRegExpRunner(`guild-${pluginData.guild.id}`);
|
state.queue = new Queue();
|
||||||
|
|
||||||
pluginData.state.recentActions = [];
|
state.regexRunner = getRegExpRunner(`guild-${guild.id}`);
|
||||||
|
|
||||||
pluginData.state.recentSpam = [];
|
state.recentActions = [];
|
||||||
|
|
||||||
pluginData.state.recentNicknameChanges = new Map();
|
state.recentSpam = [];
|
||||||
|
|
||||||
pluginData.state.ignoredRoleChanges = new Set();
|
state.recentNicknameChanges = new Map();
|
||||||
|
|
||||||
pluginData.state.cooldownManager = new CooldownManager();
|
state.ignoredRoleChanges = new Set();
|
||||||
|
|
||||||
pluginData.state.logs = new GuildLogs(pluginData.guild.id);
|
state.cooldownManager = new CooldownManager();
|
||||||
pluginData.state.savedMessages = GuildSavedMessages.getGuildInstance(pluginData.guild.id);
|
|
||||||
pluginData.state.antiraidLevels = GuildAntiraidLevels.getGuildInstance(pluginData.guild.id);
|
|
||||||
pluginData.state.archives = GuildArchives.getGuildInstance(pluginData.guild.id);
|
|
||||||
|
|
||||||
pluginData.state.cachedAntiraidLevel = await pluginData.state.antiraidLevels.get();
|
state.logs = new GuildLogs(guild.id);
|
||||||
|
state.savedMessages = GuildSavedMessages.getGuildInstance(guild.id);
|
||||||
|
state.antiraidLevels = GuildAntiraidLevels.getGuildInstance(guild.id);
|
||||||
|
state.archives = GuildArchives.getGuildInstance(guild.id);
|
||||||
|
|
||||||
|
state.cachedAntiraidLevel = await state.antiraidLevels.get();
|
||||||
},
|
},
|
||||||
|
|
||||||
async afterLoad(pluginData) {
|
async afterLoad(pluginData) {
|
||||||
pluginData.state.clearRecentActionsInterval = setInterval(() => clearOldRecentActions(pluginData), 1 * MINUTES);
|
const { state, guild } = pluginData;
|
||||||
pluginData.state.clearRecentSpamInterval = setInterval(() => clearOldRecentSpam(pluginData), 1 * SECONDS);
|
|
||||||
pluginData.state.clearRecentNicknameChangesInterval = setInterval(
|
state.clearRecentActionsInterval = setInterval(() => clearOldRecentActions(pluginData), 1 * MINUTES);
|
||||||
|
state.clearRecentSpamInterval = setInterval(() => clearOldRecentSpam(pluginData), 1 * SECONDS);
|
||||||
|
state.clearRecentNicknameChangesInterval = setInterval(
|
||||||
() => clearOldRecentNicknameChanges(pluginData),
|
() => clearOldRecentNicknameChanges(pluginData),
|
||||||
30 * SECONDS,
|
30 * SECONDS,
|
||||||
);
|
);
|
||||||
|
|
||||||
pluginData.state.onMessageCreateFn = (message) => runAutomodOnMessage(pluginData, message, false);
|
state.onMessageCreateFn = (message) => runAutomodOnMessage(pluginData, message, false);
|
||||||
pluginData.state.savedMessages.events.on("create", pluginData.state.onMessageCreateFn);
|
state.savedMessages.events.on("create", state.onMessageCreateFn);
|
||||||
|
|
||||||
pluginData.state.onMessageUpdateFn = (message) => runAutomodOnMessage(pluginData, message, true);
|
state.onMessageUpdateFn = (message) => runAutomodOnMessage(pluginData, message, true);
|
||||||
pluginData.state.savedMessages.events.on("update", pluginData.state.onMessageUpdateFn);
|
state.savedMessages.events.on("update", state.onMessageUpdateFn);
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
||||||
|
|
||||||
pluginData.state.onCounterTrigger = (name, triggerName, channelId, userId) => {
|
state.onCounterTrigger = (name, triggerName, channelId, userId) => {
|
||||||
runAutomodOnCounterTrigger(pluginData, name, triggerName, channelId, userId, false);
|
runAutomodOnCounterTrigger(pluginData, name, triggerName, channelId, userId, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
pluginData.state.onCounterReverseTrigger = (name, triggerName, channelId, userId) => {
|
state.onCounterReverseTrigger = (name, triggerName, channelId, userId) => {
|
||||||
runAutomodOnCounterTrigger(pluginData, name, triggerName, channelId, userId, true);
|
runAutomodOnCounterTrigger(pluginData, name, triggerName, channelId, userId, true);
|
||||||
};
|
};
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
countersPlugin.onCounterEvent("trigger", pluginData.state.onCounterTrigger);
|
countersPlugin.onCounterEvent("trigger", state.onCounterTrigger);
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
countersPlugin.onCounterEvent("reverseTrigger", pluginData.state.onCounterReverseTrigger);
|
countersPlugin.onCounterEvent("reverseTrigger", state.onCounterReverseTrigger);
|
||||||
|
|
||||||
const modActionsEvents = pluginData.getPlugin(ModActionsPlugin).getEventEmitter();
|
const modActionsEvents = pluginData.getPlugin(ModActionsPlugin).getEventEmitter();
|
||||||
pluginData.state.modActionsListeners = new Map();
|
state.modActionsListeners = new Map();
|
||||||
pluginData.state.modActionsListeners.set("note", (userId: string) =>
|
state.modActionsListeners.set("note", (userId: string) => runAutomodOnModAction(pluginData, "note", userId));
|
||||||
runAutomodOnModAction(pluginData, "note", userId),
|
state.modActionsListeners.set("warn", (userId: string, reason: string | undefined, isAutomodAction: boolean) =>
|
||||||
|
runAutomodOnModAction(pluginData, "warn", userId, reason, isAutomodAction),
|
||||||
);
|
);
|
||||||
pluginData.state.modActionsListeners.set(
|
state.modActionsListeners.set("kick", (userId: string, reason: string | undefined, isAutomodAction: boolean) =>
|
||||||
"warn",
|
runAutomodOnModAction(pluginData, "kick", userId, reason, isAutomodAction),
|
||||||
(userId: string, reason: string | undefined, isAutomodAction: boolean) =>
|
|
||||||
runAutomodOnModAction(pluginData, "warn", userId, reason, isAutomodAction),
|
|
||||||
);
|
);
|
||||||
pluginData.state.modActionsListeners.set(
|
state.modActionsListeners.set("ban", (userId: string, reason: string | undefined, isAutomodAction: boolean) =>
|
||||||
"kick",
|
runAutomodOnModAction(pluginData, "ban", userId, reason, isAutomodAction),
|
||||||
(userId: string, reason: string | undefined, isAutomodAction: boolean) =>
|
|
||||||
runAutomodOnModAction(pluginData, "kick", userId, reason, isAutomodAction),
|
|
||||||
);
|
);
|
||||||
pluginData.state.modActionsListeners.set(
|
state.modActionsListeners.set("unban", (userId: string) => runAutomodOnModAction(pluginData, "unban", userId));
|
||||||
"ban",
|
registerEventListenersFromMap(modActionsEvents, state.modActionsListeners);
|
||||||
(userId: string, reason: string | undefined, isAutomodAction: boolean) =>
|
|
||||||
runAutomodOnModAction(pluginData, "ban", userId, reason, isAutomodAction),
|
|
||||||
);
|
|
||||||
pluginData.state.modActionsListeners.set("unban", (userId: string) =>
|
|
||||||
runAutomodOnModAction(pluginData, "unban", userId),
|
|
||||||
);
|
|
||||||
registerEventListenersFromMap(modActionsEvents, pluginData.state.modActionsListeners);
|
|
||||||
|
|
||||||
const mutesEvents = pluginData.getPlugin(MutesPlugin).getEventEmitter();
|
const mutesEvents = pluginData.getPlugin(MutesPlugin).getEventEmitter();
|
||||||
pluginData.state.mutesListeners = new Map();
|
state.mutesListeners = new Map();
|
||||||
pluginData.state.mutesListeners.set(
|
state.mutesListeners.set("mute", (userId: string, reason: string | undefined, isAutomodAction: boolean) =>
|
||||||
"mute",
|
runAutomodOnModAction(pluginData, "mute", userId, reason, isAutomodAction),
|
||||||
(userId: string, reason: string | undefined, isAutomodAction: boolean) =>
|
|
||||||
runAutomodOnModAction(pluginData, "mute", userId, reason, isAutomodAction),
|
|
||||||
);
|
);
|
||||||
pluginData.state.mutesListeners.set("unmute", (userId: string) =>
|
state.mutesListeners.set("unmute", (userId: string) => runAutomodOnModAction(pluginData, "unmute", userId));
|
||||||
runAutomodOnModAction(pluginData, "unmute", userId),
|
registerEventListenersFromMap(mutesEvents, state.mutesListeners);
|
||||||
);
|
|
||||||
registerEventListenersFromMap(mutesEvents, pluginData.state.mutesListeners);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async beforeUnload(pluginData) {
|
async beforeUnload(pluginData) {
|
||||||
|
const { state, guild } = pluginData;
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
||||||
if (pluginData.state.onCounterTrigger) {
|
if (state.onCounterTrigger) {
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
countersPlugin.offCounterEvent("trigger", pluginData.state.onCounterTrigger);
|
countersPlugin.offCounterEvent("trigger", state.onCounterTrigger);
|
||||||
}
|
}
|
||||||
if (pluginData.state.onCounterReverseTrigger) {
|
if (state.onCounterReverseTrigger) {
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
countersPlugin.offCounterEvent("reverseTrigger", pluginData.state.onCounterReverseTrigger);
|
countersPlugin.offCounterEvent("reverseTrigger", state.onCounterReverseTrigger);
|
||||||
}
|
}
|
||||||
|
|
||||||
const modActionsEvents = pluginData.getPlugin(ModActionsPlugin).getEventEmitter();
|
const modActionsEvents = pluginData.getPlugin(ModActionsPlugin).getEventEmitter();
|
||||||
if (pluginData.state.modActionsListeners) {
|
if (state.modActionsListeners) {
|
||||||
unregisterEventListenersFromMap(modActionsEvents, pluginData.state.modActionsListeners);
|
unregisterEventListenersFromMap(modActionsEvents, state.modActionsListeners);
|
||||||
}
|
}
|
||||||
|
|
||||||
const mutesEvents = pluginData.getPlugin(MutesPlugin).getEventEmitter();
|
const mutesEvents = pluginData.getPlugin(MutesPlugin).getEventEmitter();
|
||||||
if (pluginData.state.mutesListeners) {
|
if (state.mutesListeners) {
|
||||||
unregisterEventListenersFromMap(mutesEvents, pluginData.state.mutesListeners);
|
unregisterEventListenersFromMap(mutesEvents, state.mutesListeners);
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginData.state.queue.clear();
|
state.queue.clear();
|
||||||
|
|
||||||
discardRegExpRunner(`guild-${pluginData.guild.id}`);
|
discardRegExpRunner(`guild-${guild.id}`);
|
||||||
|
|
||||||
if (pluginData.state.clearRecentActionsInterval) {
|
if (state.clearRecentActionsInterval) {
|
||||||
clearInterval(pluginData.state.clearRecentActionsInterval);
|
clearInterval(state.clearRecentActionsInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pluginData.state.clearRecentSpamInterval) {
|
if (state.clearRecentSpamInterval) {
|
||||||
clearInterval(pluginData.state.clearRecentSpamInterval);
|
clearInterval(state.clearRecentSpamInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pluginData.state.clearRecentNicknameChangesInterval) {
|
if (state.clearRecentNicknameChangesInterval) {
|
||||||
clearInterval(pluginData.state.clearRecentNicknameChangesInterval);
|
clearInterval(state.clearRecentNicknameChangesInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pluginData.state.onMessageCreateFn) {
|
if (state.onMessageCreateFn) {
|
||||||
pluginData.state.savedMessages.events.off("create", pluginData.state.onMessageCreateFn);
|
state.savedMessages.events.off("create", state.onMessageCreateFn);
|
||||||
}
|
}
|
||||||
if (pluginData.state.onMessageUpdateFn) {
|
if (state.onMessageUpdateFn) {
|
||||||
pluginData.state.savedMessages.events.off("update", pluginData.state.onMessageUpdateFn);
|
state.savedMessages.events.off("update", state.onMessageUpdateFn);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -61,17 +61,19 @@ export const BotControlPlugin = zeppelinGlobalPlugin<BotControlPluginType>()({
|
||||||
],
|
],
|
||||||
|
|
||||||
async afterLoad(pluginData) {
|
async afterLoad(pluginData) {
|
||||||
pluginData.state.archives = new GuildArchives(0);
|
const { state, client } = pluginData;
|
||||||
pluginData.state.allowedGuilds = new AllowedGuilds();
|
|
||||||
pluginData.state.configs = new Configs();
|
state.archives = new GuildArchives(0);
|
||||||
pluginData.state.apiPermissionAssignments = new ApiPermissionAssignments();
|
state.allowedGuilds = new AllowedGuilds();
|
||||||
|
state.configs = new Configs();
|
||||||
|
state.apiPermissionAssignments = new ApiPermissionAssignments();
|
||||||
|
|
||||||
const activeReload = getActiveReload();
|
const activeReload = getActiveReload();
|
||||||
if (activeReload) {
|
if (activeReload) {
|
||||||
const [guildId, channelId] = activeReload;
|
const [guildId, channelId] = activeReload;
|
||||||
resetActiveReload();
|
resetActiveReload();
|
||||||
|
|
||||||
const guild = await pluginData.client.guilds.fetch(guildId as Snowflake);
|
const guild = await client.guilds.fetch(guildId as Snowflake);
|
||||||
if (guild) {
|
if (guild) {
|
||||||
const channel = guild.channels.cache.get(channelId as Snowflake);
|
const channel = guild.channels.cache.get(channelId as Snowflake);
|
||||||
if (channel instanceof TextChannel) {
|
if (channel instanceof TextChannel) {
|
||||||
|
|
|
@ -81,9 +81,11 @@ export const CasesPlugin = zeppelinGuildPlugin<CasesPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
afterLoad(pluginData) {
|
afterLoad(pluginData) {
|
||||||
pluginData.state.logs = new GuildLogs(pluginData.guild.id);
|
const { state, guild } = pluginData;
|
||||||
pluginData.state.archives = GuildArchives.getGuildInstance(pluginData.guild.id);
|
|
||||||
pluginData.state.cases = GuildCases.getGuildInstance(pluginData.guild.id);
|
state.logs = new GuildLogs(pluginData.guild.id);
|
||||||
|
state.archives = GuildArchives.getGuildInstance(guild.id);
|
||||||
|
state.cases = GuildCases.getGuildInstance(guild.id);
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||||
|
|
|
@ -69,7 +69,7 @@ export const CensorPlugin = zeppelinGuildPlugin<CensorPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
afterLoad(pluginData) {
|
afterLoad(pluginData) {
|
||||||
const { state, guild } = pluginData;
|
const { state } = pluginData;
|
||||||
|
|
||||||
state.onMessageCreateFn = (msg) => onMessageCreate(pluginData, msg);
|
state.onMessageCreateFn = (msg) => onMessageCreate(pluginData, msg);
|
||||||
state.savedMessages.events.on("create", state.onMessageCreateFn);
|
state.savedMessages.events.on("create", state.onMessageCreateFn);
|
||||||
|
@ -79,10 +79,12 @@ export const CensorPlugin = zeppelinGuildPlugin<CensorPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeUnload(pluginData) {
|
beforeUnload(pluginData) {
|
||||||
discardRegExpRunner(`guild-${pluginData.guild.id}`);
|
const { state, guild } = pluginData;
|
||||||
|
|
||||||
pluginData.state.savedMessages.events.off("create", pluginData.state.onMessageCreateFn);
|
discardRegExpRunner(`guild-${guild.id}`);
|
||||||
pluginData.state.savedMessages.events.off("update", pluginData.state.onMessageUpdateFn);
|
|
||||||
|
state.savedMessages.events.off("create", state.onMessageCreateFn);
|
||||||
|
state.savedMessages.events.off("update", state.onMessageUpdateFn);
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { EventEmitter } from "events";
|
import { EventEmitter } from "events";
|
||||||
import { PluginOptions } from "knub";
|
import { PluginOptions } from "knub";
|
||||||
import { ConfigParserFn } from "knub/dist/config/configTypes";
|
|
||||||
import {
|
import {
|
||||||
buildCounterConditionString,
|
buildCounterConditionString,
|
||||||
CounterTrigger,
|
CounterTrigger,
|
||||||
|
@ -145,32 +144,30 @@ export const CountersPlugin = zeppelinGuildPlugin<CountersPluginType>()({
|
||||||
],
|
],
|
||||||
|
|
||||||
async beforeLoad(pluginData) {
|
async beforeLoad(pluginData) {
|
||||||
pluginData.state.counters = new GuildCounters(pluginData.guild.id);
|
const { state, guild } = pluginData;
|
||||||
pluginData.state.events = new EventEmitter();
|
|
||||||
pluginData.state.counterTriggersByCounterId = new Map();
|
state.counters = new GuildCounters(guild.id);
|
||||||
|
state.events = new EventEmitter();
|
||||||
|
state.counterTriggersByCounterId = new Map();
|
||||||
|
|
||||||
const activeTriggerIds: number[] = [];
|
const activeTriggerIds: number[] = [];
|
||||||
|
|
||||||
// Initialize and store the IDs of each of the counters internally
|
// Initialize and store the IDs of each of the counters internally
|
||||||
pluginData.state.counterIds = {};
|
state.counterIds = {};
|
||||||
const config = pluginData.config.get();
|
const config = pluginData.config.get();
|
||||||
for (const counter of Object.values(config.counters)) {
|
for (const counter of Object.values(config.counters)) {
|
||||||
const dbCounter = await pluginData.state.counters.findOrCreateCounter(
|
const dbCounter = await state.counters.findOrCreateCounter(counter.name, counter.per_channel, counter.per_user);
|
||||||
counter.name,
|
state.counterIds[counter.name] = dbCounter.id;
|
||||||
counter.per_channel,
|
|
||||||
counter.per_user,
|
|
||||||
);
|
|
||||||
pluginData.state.counterIds[counter.name] = dbCounter.id;
|
|
||||||
|
|
||||||
const thisCounterTriggers: CounterTrigger[] = [];
|
const thisCounterTriggers: CounterTrigger[] = [];
|
||||||
pluginData.state.counterTriggersByCounterId.set(dbCounter.id, thisCounterTriggers);
|
state.counterTriggersByCounterId.set(dbCounter.id, thisCounterTriggers);
|
||||||
|
|
||||||
// Initialize triggers
|
// Initialize triggers
|
||||||
for (const trigger of Object.values(counter.triggers)) {
|
for (const trigger of Object.values(counter.triggers)) {
|
||||||
const theTrigger = trigger as TTrigger;
|
const theTrigger = trigger as TTrigger;
|
||||||
const parsedCondition = parseCounterConditionString(theTrigger.condition)!;
|
const parsedCondition = parseCounterConditionString(theTrigger.condition)!;
|
||||||
const parsedReverseCondition = parseCounterConditionString(theTrigger.reverse_condition)!;
|
const parsedReverseCondition = parseCounterConditionString(theTrigger.reverse_condition)!;
|
||||||
const counterTrigger = await pluginData.state.counters.initCounterTrigger(
|
const counterTrigger = await state.counters.initCounterTrigger(
|
||||||
dbCounter.id,
|
dbCounter.id,
|
||||||
theTrigger.name,
|
theTrigger.name,
|
||||||
parsedCondition[0],
|
parsedCondition[0],
|
||||||
|
@ -184,17 +181,19 @@ export const CountersPlugin = zeppelinGuildPlugin<CountersPluginType>()({
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark old/unused counters to be deleted later
|
// Mark old/unused counters to be deleted later
|
||||||
await pluginData.state.counters.markUnusedCountersToBeDeleted([...Object.values(pluginData.state.counterIds)]);
|
await state.counters.markUnusedCountersToBeDeleted([...Object.values(state.counterIds)]);
|
||||||
|
|
||||||
// Mark old/unused triggers to be deleted later
|
// Mark old/unused triggers to be deleted later
|
||||||
await pluginData.state.counters.markUnusedTriggersToBeDeleted(activeTriggerIds);
|
await state.counters.markUnusedTriggersToBeDeleted(activeTriggerIds);
|
||||||
},
|
},
|
||||||
|
|
||||||
async afterLoad(pluginData) {
|
async afterLoad(pluginData) {
|
||||||
|
const { state } = pluginData;
|
||||||
|
|
||||||
const config = pluginData.config.get();
|
const config = pluginData.config.get();
|
||||||
|
|
||||||
// Start decay timers
|
// Start decay timers
|
||||||
pluginData.state.decayTimers = [];
|
state.decayTimers = [];
|
||||||
for (const [counterName, counter] of Object.entries(config.counters)) {
|
for (const [counterName, counter] of Object.entries(config.counters)) {
|
||||||
if (!counter.decay) {
|
if (!counter.decay) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -206,7 +205,7 @@ export const CountersPlugin = zeppelinGuildPlugin<CountersPluginType>()({
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginData.state.decayTimers.push(
|
state.decayTimers.push(
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
decayCounter(pluginData, counterName, decayPeriodMs, decay.amount);
|
decayCounter(pluginData, counterName, decayPeriodMs, decay.amount);
|
||||||
}, DECAY_APPLY_INTERVAL),
|
}, DECAY_APPLY_INTERVAL),
|
||||||
|
@ -215,12 +214,14 @@ export const CountersPlugin = zeppelinGuildPlugin<CountersPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeUnload(pluginData) {
|
beforeUnload(pluginData) {
|
||||||
if (pluginData.state.decayTimers) {
|
const { state } = pluginData;
|
||||||
for (const interval of pluginData.state.decayTimers) {
|
|
||||||
|
if (state.decayTimers) {
|
||||||
|
for (const interval of state.decayTimers) {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginData.state.events.removeAllListeners();
|
state.events.removeAllListeners();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,15 +38,17 @@ export const GuildAccessMonitorPlugin = zeppelinGlobalPlugin<GuildAccessMonitorP
|
||||||
],
|
],
|
||||||
|
|
||||||
async beforeLoad(pluginData) {
|
async beforeLoad(pluginData) {
|
||||||
pluginData.state.allowedGuilds = new AllowedGuilds();
|
const { state } = pluginData;
|
||||||
|
|
||||||
|
state.allowedGuilds = new AllowedGuilds();
|
||||||
|
|
||||||
const defaultAllowedServers = env.DEFAULT_ALLOWED_SERVERS || [];
|
const defaultAllowedServers = env.DEFAULT_ALLOWED_SERVERS || [];
|
||||||
const configs = new Configs();
|
const configs = new Configs();
|
||||||
for (const serverId of defaultAllowedServers) {
|
for (const serverId of defaultAllowedServers) {
|
||||||
if (!(await pluginData.state.allowedGuilds.isAllowed(serverId))) {
|
if (!(await state.allowedGuilds.isAllowed(serverId))) {
|
||||||
// tslint:disable-next-line:no-console
|
// tslint:disable-next-line:no-console
|
||||||
console.log(`Adding allowed-by-default server ${serverId} to the allowed servers`);
|
console.log(`Adding allowed-by-default server ${serverId} to the allowed servers`);
|
||||||
await pluginData.state.allowedGuilds.add(serverId);
|
await state.allowedGuilds.add(serverId);
|
||||||
await configs.saveNewRevision(`guild-${serverId}`, "plugins: {}", 0);
|
await configs.saveNewRevision(`guild-${serverId}`, "plugins: {}", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,10 @@ export const GuildConfigReloaderPlugin = zeppelinGlobalPlugin<GuildConfigReloade
|
||||||
configSchema: t.type({}),
|
configSchema: t.type({}),
|
||||||
|
|
||||||
async beforeLoad(pluginData) {
|
async beforeLoad(pluginData) {
|
||||||
pluginData.state.guildConfigs = new Configs();
|
const { state } = pluginData;
|
||||||
pluginData.state.highestConfigId = await pluginData.state.guildConfigs.getHighestId();
|
|
||||||
|
state.guildConfigs = new Configs();
|
||||||
|
state.highestConfigId = await state.guildConfigs.getHighestId();
|
||||||
},
|
},
|
||||||
|
|
||||||
afterLoad(pluginData) {
|
afterLoad(pluginData) {
|
||||||
|
|
|
@ -26,10 +26,12 @@ export const InternalPosterPlugin = zeppelinGuildPlugin<InternalPosterPluginType
|
||||||
},
|
},
|
||||||
|
|
||||||
async beforeLoad(pluginData) {
|
async beforeLoad(pluginData) {
|
||||||
pluginData.state.webhooks = new Webhooks();
|
const { state } = pluginData;
|
||||||
pluginData.state.queue = new Queue();
|
|
||||||
pluginData.state.missingPermissions = false;
|
state.webhooks = new Webhooks();
|
||||||
pluginData.state.webhookClientCache = new Map();
|
state.queue = new Queue();
|
||||||
|
state.missingPermissions = false;
|
||||||
|
state.webhookClientCache = new Map();
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||||
|
|
|
@ -65,14 +65,18 @@ export const LocateUserPlugin = zeppelinGuildPlugin<LocateUserPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
afterLoad(pluginData) {
|
afterLoad(pluginData) {
|
||||||
pluginData.state.unregisterGuildEventListener = onGuildEvent(pluginData.guild.id, "expiredVCAlert", (alert) =>
|
const { state, guild } = pluginData;
|
||||||
|
|
||||||
|
state.unregisterGuildEventListener = onGuildEvent(guild.id, "expiredVCAlert", (alert) =>
|
||||||
clearExpiredAlert(pluginData, alert),
|
clearExpiredAlert(pluginData, alert),
|
||||||
);
|
);
|
||||||
fillActiveAlertsList(pluginData);
|
fillActiveAlertsList(pluginData);
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeUnload(pluginData) {
|
beforeUnload(pluginData) {
|
||||||
pluginData.state.unregisterGuildEventListener?.();
|
const { state, guild } = pluginData;
|
||||||
|
|
||||||
|
state.unregisterGuildEventListener?.();
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||||
|
|
|
@ -271,7 +271,7 @@ export const LogsPlugin = zeppelinGuildPlugin<LogsPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
afterLoad(pluginData) {
|
afterLoad(pluginData) {
|
||||||
const { state, guild } = pluginData;
|
const { state } = pluginData;
|
||||||
|
|
||||||
state.logListener = ({ type, data }) => log(pluginData, type, data);
|
state.logListener = ({ type, data }) => log(pluginData, type, data);
|
||||||
state.guildLogs.on("log", state.logListener);
|
state.guildLogs.on("log", state.logListener);
|
||||||
|
@ -305,24 +305,26 @@ export const LogsPlugin = zeppelinGuildPlugin<LogsPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeUnload(pluginData) {
|
beforeUnload(pluginData) {
|
||||||
if (pluginData.state.logListener) {
|
const { state, guild } = pluginData;
|
||||||
pluginData.state.guildLogs.removeListener("log", pluginData.state.logListener);
|
|
||||||
|
if (state.logListener) {
|
||||||
|
state.guildLogs.removeListener("log", state.logListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pluginData.state.onMessageDeleteFn) {
|
if (state.onMessageDeleteFn) {
|
||||||
pluginData.state.savedMessages.events.off("delete", pluginData.state.onMessageDeleteFn);
|
state.savedMessages.events.off("delete", state.onMessageDeleteFn);
|
||||||
}
|
}
|
||||||
if (pluginData.state.onMessageDeleteBulkFn) {
|
if (state.onMessageDeleteBulkFn) {
|
||||||
pluginData.state.savedMessages.events.off("deleteBulk", pluginData.state.onMessageDeleteBulkFn);
|
state.savedMessages.events.off("deleteBulk", state.onMessageDeleteBulkFn);
|
||||||
}
|
}
|
||||||
if (pluginData.state.onMessageUpdateFn) {
|
if (state.onMessageUpdateFn) {
|
||||||
pluginData.state.savedMessages.events.off("update", pluginData.state.onMessageUpdateFn);
|
state.savedMessages.events.off("update", state.onMessageUpdateFn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pluginData.state.regexRunnerRepeatedTimeoutListener) {
|
if (state.regexRunnerRepeatedTimeoutListener) {
|
||||||
pluginData.state.regexRunner.off("repeatedTimeout", pluginData.state.regexRunnerRepeatedTimeoutListener);
|
state.regexRunner.off("repeatedTimeout", state.regexRunnerRepeatedTimeoutListener);
|
||||||
}
|
}
|
||||||
discardRegExpRunner(`guild-${pluginData.guild.id}`);
|
discardRegExpRunner(`guild-${guild.id}`);
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||||
|
|
|
@ -209,15 +209,19 @@ export const ModActionsPlugin = zeppelinGuildPlugin<ModActionsPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
afterLoad(pluginData) {
|
afterLoad(pluginData) {
|
||||||
pluginData.state.unregisterGuildEventListener = onGuildEvent(pluginData.guild.id, "expiredTempban", (tempban) =>
|
const { state, guild } = pluginData;
|
||||||
|
|
||||||
|
state.unregisterGuildEventListener = onGuildEvent(guild.id, "expiredTempban", (tempban) =>
|
||||||
clearTempban(pluginData, tempban),
|
clearTempban(pluginData, tempban),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeUnload(pluginData) {
|
beforeUnload(pluginData) {
|
||||||
pluginData.state.unloaded = true;
|
const { state, guild } = pluginData;
|
||||||
pluginData.state.unregisterGuildEventListener?.();
|
|
||||||
pluginData.state.events.removeAllListeners();
|
state.unloaded = true;
|
||||||
|
state.unregisterGuildEventListener?.();
|
||||||
|
state.events.removeAllListeners();
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||||
|
|
|
@ -104,23 +104,27 @@ export const MutesPlugin = zeppelinGuildPlugin<MutesPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeLoad(pluginData) {
|
beforeLoad(pluginData) {
|
||||||
pluginData.state.mutes = GuildMutes.getGuildInstance(pluginData.guild.id);
|
const { state, guild } = pluginData;
|
||||||
pluginData.state.cases = GuildCases.getGuildInstance(pluginData.guild.id);
|
|
||||||
pluginData.state.serverLogs = new GuildLogs(pluginData.guild.id);
|
|
||||||
pluginData.state.archives = GuildArchives.getGuildInstance(pluginData.guild.id);
|
|
||||||
|
|
||||||
pluginData.state.events = new EventEmitter();
|
state.mutes = GuildMutes.getGuildInstance(guild.id);
|
||||||
|
state.cases = GuildCases.getGuildInstance(guild.id);
|
||||||
|
state.serverLogs = new GuildLogs(guild.id);
|
||||||
|
state.archives = GuildArchives.getGuildInstance(guild.id);
|
||||||
|
|
||||||
|
state.events = new EventEmitter();
|
||||||
},
|
},
|
||||||
|
|
||||||
afterLoad(pluginData) {
|
afterLoad(pluginData) {
|
||||||
pluginData.state.unregisterGuildEventListener = onGuildEvent(pluginData.guild.id, "expiredMute", (mute) =>
|
const { state, guild } = pluginData;
|
||||||
clearMute(pluginData, mute),
|
|
||||||
);
|
state.unregisterGuildEventListener = onGuildEvent(guild.id, "expiredMute", (mute) => clearMute(pluginData, mute));
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeUnload(pluginData) {
|
beforeUnload(pluginData) {
|
||||||
pluginData.state.unregisterGuildEventListener?.();
|
const { state, guild } = pluginData;
|
||||||
pluginData.state.events.removeAllListeners();
|
|
||||||
|
state.unregisterGuildEventListener?.();
|
||||||
|
state.events.removeAllListeners();
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||||
|
|
|
@ -27,6 +27,8 @@ export const PhishermanPlugin = zeppelinGuildPlugin<PhishermanPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
async beforeLoad(pluginData) {
|
async beforeLoad(pluginData) {
|
||||||
|
const { state } = pluginData;
|
||||||
|
|
||||||
pluginData.state.validApiKey = null;
|
pluginData.state.validApiKey = null;
|
||||||
|
|
||||||
if (!hasPhishermanMasterAPIKey()) {
|
if (!hasPhishermanMasterAPIKey()) {
|
||||||
|
@ -43,7 +45,7 @@ export const PhishermanPlugin = zeppelinGuildPlugin<PhishermanPluginType>()({
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
pluginData.state.validApiKey = apiKey;
|
state.validApiKey = apiKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -61,13 +61,17 @@ export const PostPlugin = zeppelinGuildPlugin<PostPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
afterLoad(pluginData) {
|
afterLoad(pluginData) {
|
||||||
pluginData.state.unregisterGuildEventListener = onGuildEvent(pluginData.guild.id, "scheduledPost", (post) =>
|
const { state, guild } = pluginData;
|
||||||
|
|
||||||
|
state.unregisterGuildEventListener = onGuildEvent(guild.id, "scheduledPost", (post) =>
|
||||||
postScheduledPost(pluginData, post),
|
postScheduledPost(pluginData, post),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeUnload(pluginData) {
|
beforeUnload(pluginData) {
|
||||||
pluginData.state.unregisterGuildEventListener?.();
|
const { state } = pluginData;
|
||||||
|
|
||||||
|
state.unregisterGuildEventListener?.();
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||||
|
|
|
@ -79,8 +79,10 @@ export const ReactionRolesPlugin = zeppelinGuildPlugin<ReactionRolesPluginType>(
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeUnload(pluginData) {
|
beforeUnload(pluginData) {
|
||||||
if (pluginData.state.autoRefreshTimeout) {
|
const { state, guild } = pluginData;
|
||||||
clearTimeout(pluginData.state.autoRefreshTimeout);
|
|
||||||
|
if (state.autoRefreshTimeout) {
|
||||||
|
clearTimeout(state.autoRefreshTimeout);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -50,14 +50,18 @@ export const RemindersPlugin = zeppelinGuildPlugin<RemindersPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
afterLoad(pluginData) {
|
afterLoad(pluginData) {
|
||||||
pluginData.state.unregisterGuildEventListener = onGuildEvent(pluginData.guild.id, "reminder", (reminder) =>
|
const { state, guild } = pluginData;
|
||||||
|
|
||||||
|
state.unregisterGuildEventListener = onGuildEvent(guild.id, "reminder", (reminder) =>
|
||||||
postReminder(pluginData, reminder),
|
postReminder(pluginData, reminder),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeUnload(pluginData) {
|
beforeUnload(pluginData) {
|
||||||
pluginData.state.unregisterGuildEventListener?.();
|
const { state } = pluginData;
|
||||||
pluginData.state.unloaded = true;
|
|
||||||
|
state.unregisterGuildEventListener?.();
|
||||||
|
state.unloaded = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||||
|
|
|
@ -24,8 +24,10 @@ export const RoleManagerPlugin = zeppelinGuildPlugin<RoleManagerPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeLoad(pluginData) {
|
beforeLoad(pluginData) {
|
||||||
pluginData.state.roleQueue = GuildRoleQueue.getGuildInstance(pluginData.guild.id);
|
const { state, guild } = pluginData;
|
||||||
pluginData.state.pendingRoleAssignmentPromise = Promise.resolve();
|
|
||||||
|
state.roleQueue = GuildRoleQueue.getGuildInstance(guild.id);
|
||||||
|
state.pendingRoleAssignmentPromise = Promise.resolve();
|
||||||
},
|
},
|
||||||
|
|
||||||
afterLoad(pluginData) {
|
afterLoad(pluginData) {
|
||||||
|
@ -33,8 +35,10 @@ export const RoleManagerPlugin = zeppelinGuildPlugin<RoleManagerPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
async afterUnload(pluginData) {
|
async afterUnload(pluginData) {
|
||||||
pluginData.state.abortRoleAssignmentLoop = true;
|
const { state } = pluginData;
|
||||||
await pluginData.state.pendingRoleAssignmentPromise;
|
|
||||||
|
state.abortRoleAssignmentLoop = true;
|
||||||
|
await state.pendingRoleAssignmentPromise;
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||||
|
|
|
@ -79,8 +79,10 @@ export const SlowmodePlugin = zeppelinGuildPlugin<SlowmodePluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeUnload(pluginData) {
|
beforeUnload(pluginData) {
|
||||||
pluginData.state.savedMessages.events.off("create", pluginData.state.onMessageCreateFn);
|
const { state, guild } = pluginData;
|
||||||
clearInterval(pluginData.state.clearInterval);
|
|
||||||
|
state.savedMessages.events.off("create", state.onMessageCreateFn);
|
||||||
|
clearInterval(state.clearInterval);
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||||
|
|
|
@ -87,8 +87,10 @@ export const SpamPlugin = zeppelinGuildPlugin<SpamPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeUnload(pluginData) {
|
beforeUnload(pluginData) {
|
||||||
pluginData.state.savedMessages.events.off("create", pluginData.state.onMessageCreateFn);
|
const { state, guild } = pluginData;
|
||||||
clearInterval(pluginData.state.expiryInterval);
|
|
||||||
|
state.savedMessages.events.off("create", state.onMessageCreateFn);
|
||||||
|
clearInterval(state.expiryInterval);
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||||
|
|
|
@ -163,6 +163,8 @@ export const StarboardPlugin = zeppelinGuildPlugin<StarboardPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeUnload(pluginData) {
|
beforeUnload(pluginData) {
|
||||||
pluginData.state.savedMessages.events.off("delete", pluginData.state.onMessageDeleteFn);
|
const { state, guild } = pluginData;
|
||||||
|
|
||||||
|
state.savedMessages.events.off("delete", state.onMessageDeleteFn);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -131,7 +131,7 @@ export const TagsPlugin = zeppelinGuildPlugin<TagsPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
afterLoad(pluginData) {
|
afterLoad(pluginData) {
|
||||||
const { state, guild } = pluginData;
|
const { state } = pluginData;
|
||||||
|
|
||||||
state.onMessageCreateFn = (msg) => onMessageCreate(pluginData, msg);
|
state.onMessageCreateFn = (msg) => onMessageCreate(pluginData, msg);
|
||||||
state.savedMessages.events.on("create", state.onMessageCreateFn);
|
state.savedMessages.events.on("create", state.onMessageCreateFn);
|
||||||
|
@ -278,6 +278,8 @@ export const TagsPlugin = zeppelinGuildPlugin<TagsPluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeUnload(pluginData) {
|
beforeUnload(pluginData) {
|
||||||
pluginData.state.savedMessages.events.off("create", pluginData.state.onMessageCreateFn);
|
const { state, guild } = pluginData;
|
||||||
|
|
||||||
|
state.savedMessages.events.off("create", state.onMessageCreateFn);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -60,7 +60,9 @@ export const TimeAndDatePlugin = zeppelinGuildPlugin<TimeAndDatePluginType>()({
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeLoad(pluginData) {
|
beforeLoad(pluginData) {
|
||||||
pluginData.state.memberTimezones = GuildMemberTimezones.getGuildInstance(pluginData.guild.id);
|
const { state, guild } = pluginData;
|
||||||
|
|
||||||
|
state.memberTimezones = GuildMemberTimezones.getGuildInstance(guild.id);
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
// FIXME: Proper inherittance from ZeppelinPluginBlueprint
|
||||||
|
|
|
@ -18,7 +18,7 @@ export const UsernameSaverPlugin = zeppelinGuildPlugin<UsernameSaverPluginType>(
|
||||||
],
|
],
|
||||||
|
|
||||||
beforeLoad(pluginData) {
|
beforeLoad(pluginData) {
|
||||||
const { state, guild } = pluginData;
|
const { state } = pluginData;
|
||||||
|
|
||||||
state.usernameHistory = new UsernameHistory();
|
state.usernameHistory = new UsernameHistory();
|
||||||
state.updateQueue = new Queue();
|
state.updateQueue = new Queue();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue