From 9d2b37ec435e5f6408bb11ab364b4faaa09d0fca Mon Sep 17 00:00:00 2001 From: kmmiio99o Date: Wed, 1 Oct 2025 16:03:33 +0200 Subject: [PATCH] Add better choosing menu for gary API v3 --- plugins/Commands/settings.tsx | 99 +++++++++++++-------------- plugins/Commands/src/commands/gary.ts | 7 +- 2 files changed, 52 insertions(+), 54 deletions(-) diff --git a/plugins/Commands/settings.tsx b/plugins/Commands/settings.tsx index d4c384a..0762b69 100644 --- a/plugins/Commands/settings.tsx +++ b/plugins/Commands/settings.tsx @@ -31,7 +31,10 @@ if (!storage.listSettings) { if (!storage.garySettings) { storage.garySettings = { - imageSource: "gary", + useGaryAPI: true, + useCatAPI: false, + useMinkerAPI: false, + useGooberAPI: false, }; } @@ -85,43 +88,17 @@ export default function Settings() { forceRerender(); }; - const handleGarySourceChange = (source: string) => { - storage.garySettings.imageSource = source; + const handleGaryAPIToggle = (apiName: string, value: boolean) => { + // Only allow one API to be selected at a time + if (value) { + storage.garySettings.useGaryAPI = apiName === "gary"; + storage.garySettings.useCatAPI = apiName === "catapi"; + storage.garySettings.useMinkerAPI = apiName === "minker"; + storage.garySettings.useGooberAPI = apiName === "goober"; + } forceRerender(); }; - const showGarySourceSelection = () => { - alerts.showConfirmationAlert({ - title: "Choose Gary Image Source", - content: "Select an image source for the Gary command:", - confirmText: "Gary API", - cancelText: "Other Options", - confirmColor: "brand", - onConfirm: () => handleGarySourceChange("gary"), - onCancel: () => { - alerts.showConfirmationAlert({ - title: "Choose Image Source", - content: "Select from remaining options:", - confirmText: "Cat API", - cancelText: "More Options", - confirmColor: "brand", - onConfirm: () => handleGarySourceChange("catapi"), - onCancel: () => { - alerts.showConfirmationAlert({ - title: "Choose Image Source", - content: "Select from final options:", - confirmText: "Minker API", - cancelText: "Goober API", - confirmColor: "brand", - onConfirm: () => handleGarySourceChange("minker"), - onCancel: () => handleGarySourceChange("goober"), - }); - }, - }); - }, - }); - }; - return ( - {/* Gary Commands */} - - handleCommandToggle("gary", v)} - /> - - - {/* KonoChan Commands */} + {/* Gary Commands */} + + handleCommandToggle("gary", v)} + /> + handleGaryAPIToggle("gary", v)} + /> + handleGaryAPIToggle("catapi", v)} + /> + handleGaryAPIToggle("minker", v)} + /> + handleGaryAPIToggle("goober", v)} + /> + + {/* Credits */} diff --git a/plugins/Commands/src/commands/gary.ts b/plugins/Commands/src/commands/gary.ts index 828b9fe..ea44199 100644 --- a/plugins/Commands/src/commands/gary.ts +++ b/plugins/Commands/src/commands/gary.ts @@ -12,7 +12,12 @@ export const garyCommand = { options: [], execute: async (args: any, ctx: any) => { try { - const source = storage.garySettings?.imageSource || "gary"; + // Determine which API to use based on switches + let source = "gary"; // default + if (storage.garySettings?.useCatAPI) source = "catapi"; + else if (storage.garySettings?.useMinkerAPI) source = "minker"; + else if (storage.garySettings?.useGooberAPI) source = "goober"; + const imageUrl = await getGaryUrl(source); if (!imageUrl) {