From 22bd0ec422627470ad980d4fc96b30c70be8af2f Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Sat, 23 Apr 2022 20:11:46 +0300 Subject: [PATCH] fix: only allow named options for role button style Numbered options gave an error when used. --- backend/src/plugins/RoleButtons/types.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/backend/src/plugins/RoleButtons/types.ts b/backend/src/plugins/RoleButtons/types.ts index 2e5b5828..e7b4096d 100644 --- a/backend/src/plugins/RoleButtons/types.ts +++ b/backend/src/plugins/RoleButtons/types.ts @@ -3,19 +3,20 @@ import { BasePluginType } from "knub"; import { tMessageContent, tNullable } from "../../utils"; import { GuildRoleButtons } from "../../data/GuildRoleButtons"; -enum ButtonStyles { - PRIMARY = 1, - SECONDARY = 2, - SUCCESS = 3, - DANGER = 4, - // LINK = 5, We do not want users to create link buttons, but it would be style 5 -} - const RoleButtonOption = t.type({ role_id: t.string, label: tNullable(t.string), emoji: tNullable(t.string), - style: tNullable(t.keyof(ButtonStyles)), // https://discord.js.org/#/docs/discord.js/v13/typedef/MessageButtonStyle + // https://discord.js.org/#/docs/discord.js/v13/typedef/MessageButtonStyle + style: tNullable( + t.union([ + t.literal("PRIMARY"), + t.literal("SECONDARY"), + t.literal("SUCCESS"), + t.literal("DANGER"), + // t.literal("LINK"), // Role buttons don't use link buttons, but adding this here so it's documented why it's not available + ]), + ), start_new_row: tNullable(t.boolean), }); export type TRoleButtonOption = t.TypeOf;