diff --git a/backend/src/plugins/AutoDelete/AutoDeletePlugin.ts b/backend/src/plugins/AutoDelete/AutoDeletePlugin.ts index 6c8251b8..cb1348d9 100644 --- a/backend/src/plugins/AutoDelete/AutoDeletePlugin.ts +++ b/backend/src/plugins/AutoDelete/AutoDeletePlugin.ts @@ -60,4 +60,7 @@ export const AutoDeletePlugin = zeppelinGuildPlugin()({ pluginData.state.guildSavedMessages.events.off("delete", pluginData.state.onMessageDeleteFn); pluginData.state.guildSavedMessages.events.off("deleteBulk", pluginData.state.onMessageDeleteBulkFn); }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/AutoReactions/AutoReactionsPlugin.ts b/backend/src/plugins/AutoReactions/AutoReactionsPlugin.ts index 579f2f1c..f3f18e5e 100644 --- a/backend/src/plugins/AutoReactions/AutoReactionsPlugin.ts +++ b/backend/src/plugins/AutoReactions/AutoReactionsPlugin.ts @@ -57,4 +57,7 @@ export const AutoReactionsPlugin = zeppelinGuildPlugin( pluginData.state.autoReactions = GuildAutoReactions.getGuildInstance(pluginData.guild.id); pluginData.state.cache = new Map(); }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/Automod/AutomodPlugin.ts b/backend/src/plugins/Automod/AutomodPlugin.ts index 333dc29e..c0a7652a 100644 --- a/backend/src/plugins/Automod/AutomodPlugin.ts +++ b/backend/src/plugins/Automod/AutomodPlugin.ts @@ -65,12 +65,12 @@ const defaultOptions = { * Config preprocessor to set default values for triggers and perform extra validation */ -const configParser: ConfigParserFn = (options) => { - if (options.config?.rules) { +const configParser = (options) => { + if (options.rules) { // Loop through each rule - for (const [name, rule] of Object.entries(options.config.rules)) { + for (const [name, rule] of Object.entries(options.rules)) { if (rule == null) { - delete options.config.rules[name]; + delete options.rules[name]; continue; } @@ -98,7 +98,7 @@ const configParser: ConfigParserFn = (options) => { for (const triggerObj of rule["triggers"]) { for (const triggerName in triggerObj) { if (!availableTriggers[triggerName]) { - throw new StrictValidationError([`Unknown trigger '${triggerName}' in rule '${rule.name}'`]); + throw new StrictValidationError([`Unknown trigger '${triggerName}' in rule '${rule["name"]}'`]); } const triggerBlueprint = availableTriggers[triggerName]; @@ -118,11 +118,11 @@ const configParser: ConfigParserFn = (options) => { if (white && black) { throw new StrictValidationError([ - `Cannot have both blacklist and whitelist enabled at rule <${rule.name}/match_attachment_type>`, + `Cannot have both blacklist and whitelist enabled at rule <${rule["name"]}/match_attachment_type>`, ]); } else if (!white && !black) { throw new StrictValidationError([ - `Must have either blacklist or whitelist enabled at rule <${rule.name}/match_attachment_type>`, + `Must have either blacklist or whitelist enabled at rule <${rule["name"]}/match_attachment_type>`, ]); } } @@ -133,11 +133,11 @@ const configParser: ConfigParserFn = (options) => { if (white && black) { throw new StrictValidationError([ - `Cannot have both blacklist and whitelist enabled at rule <${rule.name}/match_mime_type>`, + `Cannot have both blacklist and whitelist enabled at rule <${rule["name"]}/match_mime_type>`, ]); } else if (!white && !black) { throw new StrictValidationError([ - `Must have either blacklist or whitelist enabled at rule <${rule.name}/match_mime_type>`, + `Must have either blacklist or whitelist enabled at rule <${rule["name"]}/match_mime_type>`, ]); } } @@ -148,7 +148,7 @@ const configParser: ConfigParserFn = (options) => { if (rule["actions"]) { for (const actionName in rule["actions"]) { if (!availableActions[actionName]) { - throw new StrictValidationError([`Unknown action '${actionName}' in rule '${rule.name}'`]); + throw new StrictValidationError([`Unknown action '${actionName}' in rule '${rule["name"]}'`]); } const actionBlueprint = availableActions[actionName]; @@ -164,9 +164,9 @@ const configParser: ConfigParserFn = (options) => { // Enable logging of automod actions by default if (rule["actions"]) { - for (const actionName in rule.actions) { + for (const actionName in rule["actions"]) { if (!availableActions[actionName]) { - throw new StrictValidationError([`Unknown action '${actionName}' in rule '${rule.name}'`]); + throw new StrictValidationError([`Unknown action '${actionName}' in rule '${rule["name"]}'`]); } } @@ -174,7 +174,7 @@ const configParser: ConfigParserFn = (options) => { rule["actions"]["log"] = true; } if (rule["actions"]["clean"] && rule["actions"]["start_thread"]) { - throw new StrictValidationError([`Cannot have both clean and start_thread at rule '${rule.name}'`]); + throw new StrictValidationError([`Cannot have both clean and start_thread at rule '${rule["name"]}'`]); } } } diff --git a/backend/src/plugins/BotControl/BotControlPlugin.ts b/backend/src/plugins/BotControl/BotControlPlugin.ts index 6f2d8056..0c100a28 100644 --- a/backend/src/plugins/BotControl/BotControlPlugin.ts +++ b/backend/src/plugins/BotControl/BotControlPlugin.ts @@ -80,4 +80,7 @@ export const BotControlPlugin = zeppelinGlobalPlugin()({ } } }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/Cases/CasesPlugin.ts b/backend/src/plugins/Cases/CasesPlugin.ts index 4f011982..ce1cb1ef 100644 --- a/backend/src/plugins/Cases/CasesPlugin.ts +++ b/backend/src/plugins/Cases/CasesPlugin.ts @@ -85,4 +85,7 @@ export const CasesPlugin = zeppelinGuildPlugin()({ pluginData.state.archives = GuildArchives.getGuildInstance(pluginData.guild.id); pluginData.state.cases = GuildCases.getGuildInstance(pluginData.guild.id); }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/Censor/CensorPlugin.ts b/backend/src/plugins/Censor/CensorPlugin.ts index d8b74477..08a3d5ff 100644 --- a/backend/src/plugins/Censor/CensorPlugin.ts +++ b/backend/src/plugins/Censor/CensorPlugin.ts @@ -84,4 +84,7 @@ export const CensorPlugin = zeppelinGuildPlugin()({ pluginData.state.savedMessages.events.off("create", pluginData.state.onMessageCreateFn); pluginData.state.savedMessages.events.off("update", pluginData.state.onMessageUpdateFn); }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/ChannelArchiver/ChannelArchiverPlugin.ts b/backend/src/plugins/ChannelArchiver/ChannelArchiverPlugin.ts index a0809e87..d5dbeedd 100644 --- a/backend/src/plugins/ChannelArchiver/ChannelArchiverPlugin.ts +++ b/backend/src/plugins/ChannelArchiver/ChannelArchiverPlugin.ts @@ -15,4 +15,7 @@ export const ChannelArchiverPlugin = zeppelinGuildPlugin o, }); diff --git a/backend/src/plugins/CompanionChannels/CompanionChannelsPlugin.ts b/backend/src/plugins/CompanionChannels/CompanionChannelsPlugin.ts index cadee696..20a91fc6 100644 --- a/backend/src/plugins/CompanionChannels/CompanionChannelsPlugin.ts +++ b/backend/src/plugins/CompanionChannels/CompanionChannelsPlugin.ts @@ -37,4 +37,7 @@ export const CompanionChannelsPlugin = zeppelinGuildPlugin o, }); diff --git a/backend/src/plugins/ContextMenus/ContextMenuPlugin.ts b/backend/src/plugins/ContextMenus/ContextMenuPlugin.ts index 4443bf37..6b455f7e 100644 --- a/backend/src/plugins/ContextMenus/ContextMenuPlugin.ts +++ b/backend/src/plugins/ContextMenus/ContextMenuPlugin.ts @@ -53,4 +53,7 @@ export const ContextMenuPlugin = zeppelinGuildPlugin()({ afterLoad(pluginData) { loadAllCommands(pluginData); }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/Counters/CountersPlugin.ts b/backend/src/plugins/Counters/CountersPlugin.ts index 100869c9..e6a0c7da 100644 --- a/backend/src/plugins/Counters/CountersPlugin.ts +++ b/backend/src/plugins/Counters/CountersPlugin.ts @@ -55,47 +55,6 @@ const defaultOptions: PluginOptions = { ], }; -// TODO: Fix `any` typing -const configParser: ConfigParserFn = (options: any) => { - for (const [counterName, counter] of Object.entries(options.config?.counters || {})) { - counter.name = counterName; - counter.per_user = counter.per_user ?? false; - counter.per_channel = counter.per_channel ?? false; - counter.initial_value = counter.initial_value ?? 0; - counter.triggers = counter.triggers || {}; - - if (Object.values(counter.triggers).length > MAX_TRIGGERS_PER_COUNTER) { - throw new StrictValidationError([`You can only have at most ${MAX_TRIGGERS_PER_COUNTER} triggers per counter`]); - } - - // Normalize triggers - for (const [triggerName, trigger] of Object.entries(counter.triggers)) { - const triggerObj: Partial = typeof trigger === "string" ? { condition: trigger } : trigger; - - triggerObj.name = triggerName; - const parsedCondition = parseCounterConditionString(triggerObj.condition || ""); - if (!parsedCondition) { - throw new StrictValidationError([ - `Invalid comparison in counter trigger ${counterName}/${triggerName}: "${triggerObj.condition}"`, - ]); - } - - triggerObj.condition = buildCounterConditionString(parsedCondition[0], parsedCondition[1]); - triggerObj.reverse_condition = - triggerObj.reverse_condition || - buildCounterConditionString(getReverseCounterComparisonOp(parsedCondition[0]), parsedCondition[1]); - - counter.triggers[triggerName] = triggerObj as TTrigger; - } - } - - if (Object.values(options.config?.counters || {}).length > MAX_COUNTERS) { - throw new StrictValidationError([`You can only have at most ${MAX_COUNTERS} counters`]); - } - - return options; -}; - /** * The Counters plugin keeps track of simple integer values that are tied to a user, channel, both, or neither — "counters". * These values can be changed using the functions in the plugin's public interface. @@ -118,7 +77,46 @@ export const CountersPlugin = zeppelinGuildPlugin()({ configSchema: ConfigSchema, defaultOptions, - configParser, + configParser: (options) => { + for (const [counterName, counter] of Object.entries(options.counters || {})) { + counter.name = counterName; + counter.per_user = counter.per_user ?? false; + counter.per_channel = counter.per_channel ?? false; + counter.initial_value = counter.initial_value ?? 0; + counter.triggers = counter.triggers || {}; + + if (Object.values(counter.triggers).length > MAX_TRIGGERS_PER_COUNTER) { + throw new StrictValidationError([`You can only have at most ${MAX_TRIGGERS_PER_COUNTER} triggers per counter`]); + } + + // Normalize triggers + for (const [triggerName, trigger] of Object.entries(counter.triggers)) { + const triggerObj: Partial = typeof trigger === "string" ? { condition: trigger } : trigger; + + triggerObj.name = triggerName; + const parsedCondition = parseCounterConditionString(triggerObj.condition || ""); + if (!parsedCondition) { + throw new StrictValidationError([ + `Invalid comparison in counter trigger ${counterName}/${triggerName}: "${triggerObj.condition}"`, + ]); + } + + triggerObj.condition = buildCounterConditionString(parsedCondition[0], parsedCondition[1]); + triggerObj.reverse_condition = + triggerObj.reverse_condition || + buildCounterConditionString(getReverseCounterComparisonOp(parsedCondition[0]), parsedCondition[1]); + + counter.triggers[triggerName] = triggerObj as TTrigger; + } + } + + if (Object.values(options.counters || {}).length > MAX_COUNTERS) { + throw new StrictValidationError([`You can only have at most ${MAX_COUNTERS} counters`]); + } + + // FIXME: Any typing + return options; + }, public: { counterExists: mapToPublicFn(counterExists), diff --git a/backend/src/plugins/CustomEvents/CustomEventsPlugin.ts b/backend/src/plugins/CustomEvents/CustomEventsPlugin.ts index 3c8592c6..9a45fbd8 100644 --- a/backend/src/plugins/CustomEvents/CustomEventsPlugin.ts +++ b/backend/src/plugins/CustomEvents/CustomEventsPlugin.ts @@ -66,4 +66,7 @@ export const CustomEventsPlugin = zeppelinGuildPlugin()( beforeUnload() { // TODO: Run clearTriggers() once we actually have something there }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/GuildAccessMonitor/GuildAccessMonitorPlugin.ts b/backend/src/plugins/GuildAccessMonitor/GuildAccessMonitorPlugin.ts index c0445685..9e1e8ee4 100644 --- a/backend/src/plugins/GuildAccessMonitor/GuildAccessMonitorPlugin.ts +++ b/backend/src/plugins/GuildAccessMonitor/GuildAccessMonitorPlugin.ts @@ -57,4 +57,7 @@ export const GuildAccessMonitorPlugin = zeppelinGlobalPlugin o, }); diff --git a/backend/src/plugins/GuildConfigReloader/GuildConfigReloaderPlugin.ts b/backend/src/plugins/GuildConfigReloader/GuildConfigReloaderPlugin.ts index c48745e1..cfa98274 100644 --- a/backend/src/plugins/GuildConfigReloader/GuildConfigReloaderPlugin.ts +++ b/backend/src/plugins/GuildConfigReloader/GuildConfigReloaderPlugin.ts @@ -23,4 +23,7 @@ export const GuildConfigReloaderPlugin = zeppelinGlobalPlugin o, }); diff --git a/backend/src/plugins/GuildInfoSaver/GuildInfoSaverPlugin.ts b/backend/src/plugins/GuildInfoSaver/GuildInfoSaverPlugin.ts index f84ca1aa..3ba15c30 100644 --- a/backend/src/plugins/GuildInfoSaver/GuildInfoSaverPlugin.ts +++ b/backend/src/plugins/GuildInfoSaver/GuildInfoSaverPlugin.ts @@ -30,6 +30,9 @@ export const GuildInfoSaverPlugin = zeppelinGuildPlugin o, }); async function updateGuildInfo(guild: Guild) { diff --git a/backend/src/plugins/InternalPoster/InternalPosterPlugin.ts b/backend/src/plugins/InternalPoster/InternalPosterPlugin.ts index fb47b5a3..f176463e 100644 --- a/backend/src/plugins/InternalPoster/InternalPosterPlugin.ts +++ b/backend/src/plugins/InternalPoster/InternalPosterPlugin.ts @@ -31,4 +31,7 @@ export const InternalPosterPlugin = zeppelinGuildPlugin o, }); diff --git a/backend/src/plugins/LocateUser/LocateUserPlugin.ts b/backend/src/plugins/LocateUser/LocateUserPlugin.ts index 262c2c50..9cfa726f 100644 --- a/backend/src/plugins/LocateUser/LocateUserPlugin.ts +++ b/backend/src/plugins/LocateUser/LocateUserPlugin.ts @@ -74,4 +74,7 @@ export const LocateUserPlugin = zeppelinGuildPlugin()({ beforeUnload(pluginData) { pluginData.state.unregisterGuildEventListener?.(); }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/Logs/LogsPlugin.ts b/backend/src/plugins/Logs/LogsPlugin.ts index 5000f747..658dac11 100644 --- a/backend/src/plugins/Logs/LogsPlugin.ts +++ b/backend/src/plugins/Logs/LogsPlugin.ts @@ -324,4 +324,7 @@ export const LogsPlugin = zeppelinGuildPlugin()({ } discardRegExpRunner(`guild-${pluginData.guild.id}`); }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/MessageSaver/MessageSaverPlugin.ts b/backend/src/plugins/MessageSaver/MessageSaverPlugin.ts index 21bbe6e9..3e034cce 100644 --- a/backend/src/plugins/MessageSaver/MessageSaverPlugin.ts +++ b/backend/src/plugins/MessageSaver/MessageSaverPlugin.ts @@ -45,4 +45,7 @@ export const MessageSaverPlugin = zeppelinGuildPlugin()( const { state, guild } = pluginData; state.savedMessages = GuildSavedMessages.getGuildInstance(guild.id); }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/ModActions/ModActionsPlugin.ts b/backend/src/plugins/ModActions/ModActionsPlugin.ts index 200e4d59..9a0698b2 100644 --- a/backend/src/plugins/ModActions/ModActionsPlugin.ts +++ b/backend/src/plugins/ModActions/ModActionsPlugin.ts @@ -219,4 +219,7 @@ export const ModActionsPlugin = zeppelinGuildPlugin()({ pluginData.state.unregisterGuildEventListener?.(); pluginData.state.events.removeAllListeners(); }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/Mutes/MutesPlugin.ts b/backend/src/plugins/Mutes/MutesPlugin.ts index 8f95060e..21b186d3 100644 --- a/backend/src/plugins/Mutes/MutesPlugin.ts +++ b/backend/src/plugins/Mutes/MutesPlugin.ts @@ -122,4 +122,7 @@ export const MutesPlugin = zeppelinGuildPlugin()({ pluginData.state.unregisterGuildEventListener?.(); pluginData.state.events.removeAllListeners(); }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/NameHistory/NameHistoryPlugin.ts b/backend/src/plugins/NameHistory/NameHistoryPlugin.ts index 2eef5175..5bdcaf9c 100644 --- a/backend/src/plugins/NameHistory/NameHistoryPlugin.ts +++ b/backend/src/plugins/NameHistory/NameHistoryPlugin.ts @@ -46,4 +46,7 @@ export const NameHistoryPlugin = zeppelinGuildPlugin()({ state.usernameHistory = new UsernameHistory(); state.updateQueue = new Queue(); }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/Persist/PersistPlugin.ts b/backend/src/plugins/Persist/PersistPlugin.ts index 3ba19fc3..6a3e607c 100644 --- a/backend/src/plugins/Persist/PersistPlugin.ts +++ b/backend/src/plugins/Persist/PersistPlugin.ts @@ -43,4 +43,7 @@ export const PersistPlugin = zeppelinGuildPlugin()({ state.persistedData = GuildPersistedData.getGuildInstance(guild.id); state.logs = new GuildLogs(guild.id); }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/Phisherman/PhishermanPlugin.ts b/backend/src/plugins/Phisherman/PhishermanPlugin.ts index f9b3de3f..73eacdd3 100644 --- a/backend/src/plugins/Phisherman/PhishermanPlugin.ts +++ b/backend/src/plugins/Phisherman/PhishermanPlugin.ts @@ -47,4 +47,7 @@ export const PhishermanPlugin = zeppelinGuildPlugin()({ } } }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/PingableRoles/PingableRolesPlugin.ts b/backend/src/plugins/PingableRoles/PingableRolesPlugin.ts index dc2c959e..4cab6026 100644 --- a/backend/src/plugins/PingableRoles/PingableRolesPlugin.ts +++ b/backend/src/plugins/PingableRoles/PingableRolesPlugin.ts @@ -49,4 +49,7 @@ export const PingableRolesPlugin = zeppelinGuildPlugin( state.cache = new Map(); state.timeouts = new Map(); }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/Post/PostPlugin.ts b/backend/src/plugins/Post/PostPlugin.ts index 2eed1dd9..cbafe1b6 100644 --- a/backend/src/plugins/Post/PostPlugin.ts +++ b/backend/src/plugins/Post/PostPlugin.ts @@ -69,4 +69,7 @@ export const PostPlugin = zeppelinGuildPlugin()({ beforeUnload(pluginData) { pluginData.state.unregisterGuildEventListener?.(); }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/ReactionRoles/ReactionRolesPlugin.ts b/backend/src/plugins/ReactionRoles/ReactionRolesPlugin.ts index 78554c15..ff480124 100644 --- a/backend/src/plugins/ReactionRoles/ReactionRolesPlugin.ts +++ b/backend/src/plugins/ReactionRoles/ReactionRolesPlugin.ts @@ -83,4 +83,7 @@ export const ReactionRolesPlugin = zeppelinGuildPlugin( clearTimeout(pluginData.state.autoRefreshTimeout); } }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/Reminders/RemindersPlugin.ts b/backend/src/plugins/Reminders/RemindersPlugin.ts index 87a488dd..48bc13fa 100644 --- a/backend/src/plugins/Reminders/RemindersPlugin.ts +++ b/backend/src/plugins/Reminders/RemindersPlugin.ts @@ -59,4 +59,7 @@ export const RemindersPlugin = zeppelinGuildPlugin()({ pluginData.state.unregisterGuildEventListener?.(); pluginData.state.unloaded = true; }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/RoleButtons/RoleButtonsPlugin.ts b/backend/src/plugins/RoleButtons/RoleButtonsPlugin.ts index 1f68943e..7126a495 100644 --- a/backend/src/plugins/RoleButtons/RoleButtonsPlugin.ts +++ b/backend/src/plugins/RoleButtons/RoleButtonsPlugin.ts @@ -34,9 +34,9 @@ export const RoleButtonsPlugin = zeppelinGuildPlugin()({ configParser(options) { // Auto-fill "name" property for buttons based on the object key - const buttonsArray = Array.isArray(options.config?.buttons) ? options.config.buttons : []; + const buttonsArray = Array.isArray(options.buttons) ? options.buttons : []; const seenMessages = new Set(); - for (const [name, buttonsConfig] of Object.entries(options.config?.buttons ?? {})) { + for (const [name, buttonsConfig] of Object.entries(options.buttons ?? {})) { if (name.length > 16) { throw new StrictValidationError(["Name for role buttons can be at most 16 characters long"]); } @@ -66,7 +66,8 @@ export const RoleButtonsPlugin = zeppelinGuildPlugin()({ } } - return options; + // FIXME: any typing lol + return options; }, dependencies: () => [LogsPlugin, RoleManagerPlugin], diff --git a/backend/src/plugins/RoleManager/RoleManagerPlugin.ts b/backend/src/plugins/RoleManager/RoleManagerPlugin.ts index c6d398f1..9cff63f5 100644 --- a/backend/src/plugins/RoleManager/RoleManagerPlugin.ts +++ b/backend/src/plugins/RoleManager/RoleManagerPlugin.ts @@ -36,4 +36,7 @@ export const RoleManagerPlugin = zeppelinGuildPlugin()({ pluginData.state.abortRoleAssignmentLoop = true; await pluginData.state.pendingRoleAssignmentPromise; }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/Roles/RolesPlugin.ts b/backend/src/plugins/Roles/RolesPlugin.ts index fa28bfec..6a50201e 100644 --- a/backend/src/plugins/Roles/RolesPlugin.ts +++ b/backend/src/plugins/Roles/RolesPlugin.ts @@ -58,4 +58,7 @@ export const RolesPlugin = zeppelinGuildPlugin()({ state.logs = new GuildLogs(guild.id); }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/SelfGrantableRoles/SelfGrantableRolesPlugin.ts b/backend/src/plugins/SelfGrantableRoles/SelfGrantableRolesPlugin.ts index 54ab0f82..67c8a435 100644 --- a/backend/src/plugins/SelfGrantableRoles/SelfGrantableRolesPlugin.ts +++ b/backend/src/plugins/SelfGrantableRoles/SelfGrantableRolesPlugin.ts @@ -71,7 +71,7 @@ export const SelfGrantableRolesPlugin = zeppelinGuildPlugin { - const config = options.config; + const config = options; for (const [key, entry] of Object.entries(config.entries)) { // Apply default entry config config.entries[key] = { ...defaultSelfGrantableRoleEntry, ...entry }; diff --git a/backend/src/plugins/Slowmode/SlowmodePlugin.ts b/backend/src/plugins/Slowmode/SlowmodePlugin.ts index 28400c86..dbc60e5f 100644 --- a/backend/src/plugins/Slowmode/SlowmodePlugin.ts +++ b/backend/src/plugins/Slowmode/SlowmodePlugin.ts @@ -82,4 +82,7 @@ export const SlowmodePlugin = zeppelinGuildPlugin()({ pluginData.state.savedMessages.events.off("create", pluginData.state.onMessageCreateFn); clearInterval(pluginData.state.clearInterval); }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/Spam/SpamPlugin.ts b/backend/src/plugins/Spam/SpamPlugin.ts index 84182993..d4bbfeb5 100644 --- a/backend/src/plugins/Spam/SpamPlugin.ts +++ b/backend/src/plugins/Spam/SpamPlugin.ts @@ -90,4 +90,7 @@ export const SpamPlugin = zeppelinGuildPlugin()({ pluginData.state.savedMessages.events.off("create", pluginData.state.onMessageCreateFn); clearInterval(pluginData.state.expiryInterval); }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/Starboard/StarboardPlugin.ts b/backend/src/plugins/Starboard/StarboardPlugin.ts index 5aebace0..3ec21483 100644 --- a/backend/src/plugins/Starboard/StarboardPlugin.ts +++ b/backend/src/plugins/Starboard/StarboardPlugin.ts @@ -125,13 +125,14 @@ export const StarboardPlugin = zeppelinGuildPlugin()({ }, configParser(options) { - if (options.config?.boards) { - for (const [name, opts] of Object.entries(options.config.boards)) { - options.config.boards[name] = Object.assign({}, defaultStarboardOpts, options.config.boards[name]); + if (options.boards) { + for (const [name, opts] of Object.entries(options.boards)) { + options.boards[name] = Object.assign({}, defaultStarboardOpts, options.boards[name]); } } - return options; + // FIXME: any typing lol + return options; }, // prettier-ignore diff --git a/backend/src/plugins/Tags/TagsPlugin.ts b/backend/src/plugins/Tags/TagsPlugin.ts index d4272eae..1f933fd9 100644 --- a/backend/src/plugins/Tags/TagsPlugin.ts +++ b/backend/src/plugins/Tags/TagsPlugin.ts @@ -97,16 +97,16 @@ export const TagsPlugin = zeppelinGuildPlugin()({ }, configParser(options) { - if (options.config.delete_with_command && options.config.auto_delete_command) { + if (options.delete_with_command && options.auto_delete_command) { throw new StrictValidationError([ `Cannot have both (global) delete_with_command and global_delete_invoke enabled`, ]); } // Check each category for conflicting options - if (options.config?.categories) { - for (const [name, opts] of Object.entries(options.config.categories)) { - const cat = options.config.categories[name]; + if (options.categories) { + for (const [name, opts] of Object.entries(options.categories)) { + const cat = options.categories[name]; if (cat.delete_with_command && cat.auto_delete_command) { throw new StrictValidationError([ `Cannot have both (category specific) delete_with_command and category_delete_invoke enabled at `, @@ -115,7 +115,8 @@ export const TagsPlugin = zeppelinGuildPlugin()({ } } - return options; + // FIXME: any typing lol + return options; }, beforeLoad(pluginData) { diff --git a/backend/src/plugins/TimeAndDate/TimeAndDatePlugin.ts b/backend/src/plugins/TimeAndDate/TimeAndDatePlugin.ts index c4f9d877..454af3c7 100644 --- a/backend/src/plugins/TimeAndDate/TimeAndDatePlugin.ts +++ b/backend/src/plugins/TimeAndDate/TimeAndDatePlugin.ts @@ -1,6 +1,6 @@ import { PluginOptions } from "knub"; import { GuildMemberTimezones } from "../../data/GuildMemberTimezones"; -import { mapToPublicFn } from "../../pluginUtils"; +import { getPluginConfigParser, mapToPublicFn } from "../../pluginUtils"; import { trimPluginDescription } from "../../utils"; import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint"; import { ResetTimezoneCmd } from "./commands/ResetTimezoneCmd"; @@ -62,4 +62,7 @@ export const TimeAndDatePlugin = zeppelinGuildPlugin()({ beforeLoad(pluginData) { pluginData.state.memberTimezones = GuildMemberTimezones.getGuildInstance(pluginData.guild.id); }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/UsernameSaver/UsernameSaverPlugin.ts b/backend/src/plugins/UsernameSaver/UsernameSaverPlugin.ts index 3014350c..abae2aef 100644 --- a/backend/src/plugins/UsernameSaver/UsernameSaverPlugin.ts +++ b/backend/src/plugins/UsernameSaver/UsernameSaverPlugin.ts @@ -23,4 +23,7 @@ export const UsernameSaverPlugin = zeppelinGuildPlugin( state.usernameHistory = new UsernameHistory(); state.updateQueue = new Queue(); }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/Utility/UtilityPlugin.ts b/backend/src/plugins/Utility/UtilityPlugin.ts index e3998a11..d26ed836 100644 --- a/backend/src/plugins/Utility/UtilityPlugin.ts +++ b/backend/src/plugins/Utility/UtilityPlugin.ts @@ -221,4 +221,7 @@ export const UtilityPlugin = zeppelinGuildPlugin()({ beforeUnload(pluginData) { discardRegExpRunner(`guild-${pluginData.guild.id}`); }, + + // FIXME: Proper inherittance from ZeppelinPluginBlueprint + configParser: (o: any) => o, }); diff --git a/backend/src/plugins/WelcomeMessage/WelcomeMessagePlugin.ts b/backend/src/plugins/WelcomeMessage/WelcomeMessagePlugin.ts index 1bbcdb45..60d7ca07 100644 --- a/backend/src/plugins/WelcomeMessage/WelcomeMessagePlugin.ts +++ b/backend/src/plugins/WelcomeMessage/WelcomeMessagePlugin.ts @@ -35,4 +35,7 @@ export const WelcomeMessagePlugin = zeppelinGuildPlugin o, }); diff --git a/backend/src/plugins/ZeppelinPluginBlueprint.ts b/backend/src/plugins/ZeppelinPluginBlueprint.ts index c5e63e32..acfe6d40 100644 --- a/backend/src/plugins/ZeppelinPluginBlueprint.ts +++ b/backend/src/plugins/ZeppelinPluginBlueprint.ts @@ -30,7 +30,8 @@ export interface ZeppelinGuildPluginBlueprint Awaitable>; @@ -67,7 +68,8 @@ export function zeppelinGuildPlugin(...args) { export interface ZeppelinGlobalPluginBlueprint extends GlobalPluginBlueprint> { configSchema: t.TypeC; - configParser?: (options: TPluginType["config"], strict?: boolean) => Awaitable>; + // FIXME: need proper typings here + configParser: (options: TPluginType["config"], strict?: boolean) => Awaitable>; } export function zeppelinGlobalPlugin(