From 2f8fbbb03eef15f1088a42d0c96e040224600a10 Mon Sep 17 00:00:00 2001 From: nin0 Date: Wed, 16 Oct 2024 23:38:57 -0400 Subject: [PATCH] fix horrors --- index.tsx | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/index.tsx b/index.tsx index 92685c5..ada4bc1 100644 --- a/index.tsx +++ b/index.tsx @@ -14,6 +14,13 @@ import { Message } from "discord-types/general"; let userFlags = new Map(); +enum FlagType { + DANGER = "danger", + WARNING = "warning", + INFO = "info", + POSITIVE = "positive" +} + type FlagRegistryEntry = { label: string; color: string; @@ -21,32 +28,32 @@ type FlagRegistryEntry = { }; // worst typing ever? -const flagRegistry = { - danger: { +const flagRegistry: { [key in FlagType]: FlagRegistryEntry } = { + [FlagType.DANGER]: { label: "Danger", color: "#ff7473", emoji: "🛑" } as FlagRegistryEntry, - warning: { + [FlagType.WARNING]: { label: "Warning", color: "#ffb02e", emoji: "⚠️" } as FlagRegistryEntry, - info: { + [FlagType.INFO]: { label: "Info", color: "#62a8ff", emoji: "🔵" } as FlagRegistryEntry, - positive: { + [FlagType.POSITIVE]: { label: "Positive", color: "#62ff74", emoji: "✅" - } as FlagRegistryEntry -} as const; + } +}; type Flag = { - type: keyof typeof flagRegistry; + type: FlagType; text: string; }; @@ -117,7 +124,7 @@ export default definePlugin({ ], execute: async (args: Argument[], ctx: CommandContext) => { const user = findOption(args, "user", ""); - const type: Flag["type"] = findOption(args, "type", "info"); + const type = findOption(args, "type", FlagType.INFO); const text = findOption(args, "message", ""); userFlags.set(user, { type,