From ab57916a52dea01388db017e72b72549eedc5f8e Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Sat, 31 May 2025 23:00:30 +0000 Subject: [PATCH] fix: custom_events config types not allowing template variables --- backend/src/plugins/CustomEvents/actions/addRoleAction.ts | 4 ++-- .../src/plugins/CustomEvents/actions/createCaseAction.ts | 6 +++--- .../CustomEvents/actions/moveToVoiceChannelAction.ts | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/src/plugins/CustomEvents/actions/addRoleAction.ts b/backend/src/plugins/CustomEvents/actions/addRoleAction.ts index 8d7ca355..0992cc33 100644 --- a/backend/src/plugins/CustomEvents/actions/addRoleAction.ts +++ b/backend/src/plugins/CustomEvents/actions/addRoleAction.ts @@ -2,14 +2,14 @@ import { GuildPluginData } from "knub"; import z from "zod/v4"; import { canActOn } from "../../../pluginUtils.js"; import { renderTemplate, TemplateSafeValueContainer } from "../../../templateFormatter.js"; -import { resolveMember, zSnowflake } from "../../../utils.js"; +import { resolveMember, zBoundedCharacters, zSnowflake } from "../../../utils.js"; import { ActionError } from "../ActionError.js"; import { catchTemplateError } from "../catchTemplateError.js"; import { CustomEventsPluginType, TCustomEvent } from "../types.js"; export const zAddRoleAction = z.strictObject({ type: z.literal("add_role"), - target: zSnowflake, + target: zBoundedCharacters(0, 100), role: z.union([zSnowflake, z.array(zSnowflake)]), }); export type TAddRoleAction = z.infer; diff --git a/backend/src/plugins/CustomEvents/actions/createCaseAction.ts b/backend/src/plugins/CustomEvents/actions/createCaseAction.ts index 0ab98c56..3b00e7d7 100644 --- a/backend/src/plugins/CustomEvents/actions/createCaseAction.ts +++ b/backend/src/plugins/CustomEvents/actions/createCaseAction.ts @@ -2,7 +2,7 @@ import { GuildPluginData } from "knub"; import z from "zod/v4"; import { CaseTypes } from "../../../data/CaseTypes.js"; import { renderTemplate, TemplateSafeValueContainer } from "../../../templateFormatter.js"; -import { zBoundedCharacters, zSnowflake } from "../../../utils.js"; +import { zBoundedCharacters } from "../../../utils.js"; import { CasesPlugin } from "../../Cases/CasesPlugin.js"; import { ActionError } from "../ActionError.js"; import { catchTemplateError } from "../catchTemplateError.js"; @@ -11,8 +11,8 @@ import { CustomEventsPluginType, TCustomEvent } from "../types.js"; export const zCreateCaseAction = z.strictObject({ type: z.literal("create_case"), case_type: zBoundedCharacters(0, 32), - mod: zSnowflake, - target: zSnowflake, + mod: zBoundedCharacters(0, 100), + target: zBoundedCharacters(0, 100), reason: zBoundedCharacters(0, 4000), }); export type TCreateCaseAction = z.infer; diff --git a/backend/src/plugins/CustomEvents/actions/moveToVoiceChannelAction.ts b/backend/src/plugins/CustomEvents/actions/moveToVoiceChannelAction.ts index 2b08162f..ebc83383 100644 --- a/backend/src/plugins/CustomEvents/actions/moveToVoiceChannelAction.ts +++ b/backend/src/plugins/CustomEvents/actions/moveToVoiceChannelAction.ts @@ -3,14 +3,14 @@ import { GuildPluginData } from "knub"; import z from "zod/v4"; import { canActOn } from "../../../pluginUtils.js"; import { TemplateSafeValueContainer, renderTemplate } from "../../../templateFormatter.js"; -import { resolveMember, zSnowflake } from "../../../utils.js"; +import { resolveMember, zBoundedCharacters, zSnowflake } from "../../../utils.js"; import { ActionError } from "../ActionError.js"; import { catchTemplateError } from "../catchTemplateError.js"; import { CustomEventsPluginType, TCustomEvent } from "../types.js"; export const zMoveToVoiceChannelAction = z.strictObject({ type: z.literal("move_to_vc"), - target: zSnowflake, + target: zBoundedCharacters(0, 100), channel: zSnowflake, }); export type TMoveToVoiceChannelAction = z.infer;