From a80af1e729b742d1aad1097df538d224fbd32ce7 Mon Sep 17 00:00:00 2001 From: metal Date: Mon, 13 Mar 2023 10:02:54 +0000 Subject: [PATCH] +debug build method (revert this) Signed-off-by: GitHub --- .devcontainer/devcontainer.json | 9 --------- backend/package-lock.json | 14 +++++++------- backend/package.json | 2 +- backend/src/index.ts | 2 ++ backend/src/pluginUtils.ts | 11 ++++++++++- backend/src/plugins/Automod/AutomodPlugin.ts | 9 +++++++-- .../src/plugins/Automod/actions/addToCounter.ts | 3 +++ backend/src/plugins/Automod/actions/setCounter.ts | 3 +++ .../Automod/events/runAutomodOnCounterTrigger.ts | 4 +++- backend/src/plugins/Utility/commands/HelpCmd.ts | 1 + .../Utility/functions/getMessageInfoEmbed.ts | 1 + backend/src/plugins/ZeppelinPluginBlueprint.ts | 4 ++-- 12 files changed, 40 insertions(+), 23 deletions(-) delete mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index 0d15eb29..00000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "Zeppelin Development", - - "dockerComposeFile": "../docker-compose.development.yml", - - "service": "devenv", - "remoteUser": "ubuntu", - "workspaceFolder": "/home/ubuntu/zeppelin" -} diff --git a/backend/package-lock.json b/backend/package-lock.json index 5638ff04..1bdf9bd9 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -23,7 +23,7 @@ "humanize-duration": "^3.15.0", "io-ts": "^2.0.0", "js-yaml": "^3.13.1", - "knub": "^32.0.0-next.0", + "knub": "^31.0.0", "knub-command-manager": "^9.1.0", "last-commit-log": "^2.1.0", "lodash.chunk": "^4.2.0", @@ -2704,9 +2704,9 @@ } }, "node_modules/knub": { - "version": "32.0.0-next.0", - "resolved": "https://registry.npmjs.org/knub/-/knub-32.0.0-next.0.tgz", - "integrity": "sha512-tT27Qr8qpge+EWonrMyw54mZ67/1WP3oKF7QgTdK6cYArTdERuYxF9X7ngd9JXcVeW9/WYz/62jq42/w9lDzIA==", + "version": "31.0.0", + "resolved": "https://registry.npmjs.org/knub/-/knub-31.0.0.tgz", + "integrity": "sha512-mm2PrtQ9G5UoELfJ4kjWaNQZZRMhwJbCf4FgJj92iDy4pg95XPNWAkwTw8avbkslNjb9m5Va1pp3IeJayvz/ag==", "dependencies": { "discord-api-types": "^0.37.10", "discord.js": "^14", @@ -7199,9 +7199,9 @@ } }, "knub": { - "version": "32.0.0-next.0", - "resolved": "https://registry.npmjs.org/knub/-/knub-32.0.0-next.0.tgz", - "integrity": "sha512-tT27Qr8qpge+EWonrMyw54mZ67/1WP3oKF7QgTdK6cYArTdERuYxF9X7ngd9JXcVeW9/WYz/62jq42/w9lDzIA==", + "version": "31.0.0", + "resolved": "https://registry.npmjs.org/knub/-/knub-31.0.0.tgz", + "integrity": "sha512-mm2PrtQ9G5UoELfJ4kjWaNQZZRMhwJbCf4FgJj92iDy4pg95XPNWAkwTw8avbkslNjb9m5Va1pp3IeJayvz/ag==", "requires": { "discord-api-types": "^0.37.10", "discord.js": "^14", diff --git a/backend/package.json b/backend/package.json index 95b0a52b..d14c8da7 100644 --- a/backend/package.json +++ b/backend/package.json @@ -38,7 +38,7 @@ "humanize-duration": "^3.15.0", "io-ts": "^2.0.0", "js-yaml": "^3.13.1", - "knub": "^32.0.0-next.0", + "knub": "^31.0.0", "knub-command-manager": "^9.1.0", "last-commit-log": "^2.1.0", "lodash.chunk": "^4.2.0", diff --git a/backend/src/index.ts b/backend/src/index.ts index e93e17df..f01003cf 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -354,6 +354,7 @@ connect().then(async () => { sendSuccessMessageFn(channel, body) { const guildId = channel instanceof TextChannel || channel instanceof ThreadChannel ? channel.guild.id : undefined; + // @ts-expect-error const emoji = guildId ? bot.getLoadedGuild(guildId)!.config.success_emoji : undefined; channel.send(successMessage(body, emoji)); }, @@ -361,6 +362,7 @@ connect().then(async () => { sendErrorMessageFn(channel, body) { const guildId = channel instanceof TextChannel || channel instanceof ThreadChannel ? channel.guild.id : undefined; + // @ts-expect-error const emoji = guildId ? bot.getLoadedGuild(guildId)!.config.error_emoji : undefined; channel.send(errorMessage(body, emoji)); }, diff --git a/backend/src/pluginUtils.ts b/backend/src/pluginUtils.ts index e654f630..4c110914 100644 --- a/backend/src/pluginUtils.ts +++ b/backend/src/pluginUtils.ts @@ -93,6 +93,11 @@ export function strictValidationErrorToConfigValidationError(err: StrictValidati export function getPluginConfigParser(blueprint: ZeppelinPlugin, customParser?: ZeppelinPlugin["configParser"]) { return async (options: PluginOptions, strict?: boolean) => { + const ident = `[getPluginConfigParser.${blueprint.name}] | `; + if (blueprint.name === "mutes") { + console.log(ident, "options => ", JSON.stringify(options)); + } + // 1. Validate the basic structure of plugin config const basicOptionsValidation = validate(BasicPluginStructureType, options); if (basicOptionsValidation instanceof StrictValidationError) { @@ -142,7 +147,7 @@ export function getPluginConfigParser(blueprint: ZeppelinPlugin, customParser?: } } - // 3. Run custom preprocessor, if any + // 3. Run custom parser, if any if (customParser) { options = await customParser(options); } @@ -156,6 +161,7 @@ export function getPluginConfigParser(blueprint: ZeppelinPlugin, customParser?: ? decodeAndValidateStrict(blueprint.configSchema, options.config) : options.config; if (decodedConfig instanceof StrictValidationError) { + console.error("4.strict:", blueprint.name); throw strictValidationErrorToConfigValidationError(decodedConfig); } } @@ -167,6 +173,7 @@ export function getPluginConfigParser(blueprint: ZeppelinPlugin, customParser?: ? decodeAndValidateStrict(blueprint.configSchema, overrideConfigMergedWithBaseConfig) : overrideConfigMergedWithBaseConfig; if (decodedOverrideConfig instanceof StrictValidationError) { + console.error("4.overrides.strict:", blueprint.name, options, decodedOverrideConfig); throw strictValidationErrorToConfigValidationError(decodedOverrideConfig); } decodedOverrides.push({ @@ -227,11 +234,13 @@ export async function sendErrorMessage( export function getBaseUrl(pluginData: AnyPluginData) { const knub = pluginData.getKnubInstance() as TZeppelinKnub; + // @ts-expect-error return knub.getGlobalConfig().url; } export function isOwner(pluginData: AnyPluginData, userId: string) { const knub = pluginData.getKnubInstance() as TZeppelinKnub; + // @ts-expect-error const owners = knub.getGlobalConfig()?.owners; if (!owners) { return false; diff --git a/backend/src/plugins/Automod/AutomodPlugin.ts b/backend/src/plugins/Automod/AutomodPlugin.ts index 15a5c7b4..3fe5d0c1 100644 --- a/backend/src/plugins/Automod/AutomodPlugin.ts +++ b/backend/src/plugins/Automod/AutomodPlugin.ts @@ -188,6 +188,7 @@ export const AutomodPlugin = zeppelinGuildPlugin()({ info: pluginInfo, // prettier-ignore + // @ts-expect-error dependencies: () => [ LogsPlugin, ModActionsPlugin, @@ -256,7 +257,7 @@ export const AutomodPlugin = zeppelinGuildPlugin()({ pluginData.state.onMessageUpdateFn = (message) => runAutomodOnMessage(pluginData, message, true); pluginData.state.savedMessages.events.on("update", pluginData.state.onMessageUpdateFn); - + // @ts-expect-error const countersPlugin = pluginData.getPlugin(CountersPlugin); pluginData.state.onCounterTrigger = (name, triggerName, channelId, userId) => { @@ -266,8 +267,9 @@ export const AutomodPlugin = zeppelinGuildPlugin()({ pluginData.state.onCounterReverseTrigger = (name, triggerName, channelId, userId) => { runAutomodOnCounterTrigger(pluginData, name, triggerName, channelId, userId, true); }; - + // @ts-expect-error countersPlugin.onCounterEvent("trigger", pluginData.state.onCounterTrigger); + // @ts-expect-error countersPlugin.onCounterEvent("reverseTrigger", pluginData.state.onCounterReverseTrigger); const modActionsEvents = pluginData.getPlugin(ModActionsPlugin).getEventEmitter(); @@ -309,11 +311,14 @@ export const AutomodPlugin = zeppelinGuildPlugin()({ }, async beforeUnload(pluginData) { + // @ts-expect-error const countersPlugin = pluginData.getPlugin(CountersPlugin); if (pluginData.state.onCounterTrigger) { + // @ts-expect-error countersPlugin.offCounterEvent("trigger", pluginData.state.onCounterTrigger); } if (pluginData.state.onCounterReverseTrigger) { + // @ts-expect-error countersPlugin.offCounterEvent("reverseTrigger", pluginData.state.onCounterReverseTrigger); } diff --git a/backend/src/plugins/Automod/actions/addToCounter.ts b/backend/src/plugins/Automod/actions/addToCounter.ts index 7e7f4ac8..d1876fb0 100644 --- a/backend/src/plugins/Automod/actions/addToCounter.ts +++ b/backend/src/plugins/Automod/actions/addToCounter.ts @@ -12,7 +12,9 @@ export const AddToCounterAction = automodAction({ defaultConfig: {}, async apply({ pluginData, contexts, actionConfig, matchResult, ruleName }) { + // @ts-expect-error const countersPlugin = pluginData.getPlugin(CountersPlugin); + // @ts-expect-error if (!countersPlugin.counterExists(actionConfig.counter)) { pluginData.getPlugin(LogsPlugin).logBotAlert({ body: `Unknown counter \`${actionConfig.counter}\` in \`add_to_counter\` action of Automod rule \`${ruleName}\``, @@ -20,6 +22,7 @@ export const AddToCounterAction = automodAction({ return; } + // @ts-expect-error countersPlugin.changeCounterValue( actionConfig.counter, contexts[0].message?.channel_id || null, diff --git a/backend/src/plugins/Automod/actions/setCounter.ts b/backend/src/plugins/Automod/actions/setCounter.ts index 5206e579..00897ef8 100644 --- a/backend/src/plugins/Automod/actions/setCounter.ts +++ b/backend/src/plugins/Automod/actions/setCounter.ts @@ -12,7 +12,9 @@ export const SetCounterAction = automodAction({ defaultConfig: {}, async apply({ pluginData, contexts, actionConfig, matchResult, ruleName }) { + // @ts-expect-error const countersPlugin = pluginData.getPlugin(CountersPlugin); + // @ts-expect-error if (!countersPlugin.counterExists(actionConfig.counter)) { pluginData.getPlugin(LogsPlugin).logBotAlert({ body: `Unknown counter \`${actionConfig.counter}\` in \`add_to_counter\` action of Automod rule \`${ruleName}\``, @@ -20,6 +22,7 @@ export const SetCounterAction = automodAction({ return; } + // @ts-expect-error countersPlugin.setCounterValue( actionConfig.counter, contexts[0].message?.channel_id || null, diff --git a/backend/src/plugins/Automod/events/runAutomodOnCounterTrigger.ts b/backend/src/plugins/Automod/events/runAutomodOnCounterTrigger.ts index 01f75116..125e3854 100644 --- a/backend/src/plugins/Automod/events/runAutomodOnCounterTrigger.ts +++ b/backend/src/plugins/Automod/events/runAutomodOnCounterTrigger.ts @@ -14,9 +14,11 @@ export async function runAutomodOnCounterTrigger( ) { const user = userId ? await resolveUser(pluginData.client, userId) : undefined; const member = (userId && (await resolveMember(pluginData.client, pluginData.guild, userId))) || undefined; - + // @ts-expect-error const prettyCounterName = pluginData.getPlugin(CountersPlugin).getPrettyNameForCounter(counterName); + // @ts-expect-error const prettyTriggerName = pluginData + // @ts-expect-error .getPlugin(CountersPlugin) .getPrettyNameForCounterTrigger(counterName, triggerName); diff --git a/backend/src/plugins/Utility/commands/HelpCmd.ts b/backend/src/plugins/Utility/commands/HelpCmd.ts index 5094dcc8..d4b0e859 100644 --- a/backend/src/plugins/Utility/commands/HelpCmd.ts +++ b/backend/src/plugins/Utility/commands/HelpCmd.ts @@ -32,6 +32,7 @@ export const HelpCmd = utilityCmd({ if (strTrigger.startsWith(searchStr)) { matchingCommands.push({ plugin, + // @ts-expect-error command: registeredCommand, }); break; diff --git a/backend/src/plugins/Utility/functions/getMessageInfoEmbed.ts b/backend/src/plugins/Utility/functions/getMessageInfoEmbed.ts index 056aae2c..3f15e87f 100644 --- a/backend/src/plugins/Utility/functions/getMessageInfoEmbed.ts +++ b/backend/src/plugins/Utility/functions/getMessageInfoEmbed.ts @@ -136,6 +136,7 @@ export async function getMessageInfoEmbed( } if (message.embeds.length) { + // @ts-expect-error const prefix = pluginData.fullConfig.prefix || getDefaultPrefix(pluginData.client); embed.fields.push({ name: preEmbedPadding + "Embeds", diff --git a/backend/src/plugins/ZeppelinPluginBlueprint.ts b/backend/src/plugins/ZeppelinPluginBlueprint.ts index acfe6d40..783d327d 100644 --- a/backend/src/plugins/ZeppelinPluginBlueprint.ts +++ b/backend/src/plugins/ZeppelinPluginBlueprint.ts @@ -54,7 +54,7 @@ export function zeppelinGuildPlugin(...args) { const blueprint = guildPlugin( ...(args as Parameters), ) as unknown as ZeppelinGuildPluginBlueprint; - blueprint.configParser = getPluginConfigParser(blueprint, blueprint.configParser); + blueprint.configParser = getPluginConfigParser(blueprint, blueprint.configParser); return blueprint; } else { return zeppelinGuildPlugin as (name, blueprint) => ZeppelinGuildPluginBlueprint; @@ -89,7 +89,7 @@ export function zeppelinGlobalPlugin(...args) { const blueprint = globalPlugin( ...(args as Parameters), ) as unknown as ZeppelinGlobalPluginBlueprint; - // @ts-ignore FIXME: Check the types here + // @ts-expect-error FIXME: Check the types here blueprint.configParser = getPluginConfigParser(blueprint, blueprint.configParser); return blueprint; } else {