From 16081d8f8d00dbd68e1925e8d72af78840259b10 Mon Sep 17 00:00:00 2001 From: kmmiio99o Date: Wed, 1 Oct 2025 15:41:01 +0200 Subject: [PATCH] GARYYYY --- plugins/Commands/index.ts | 9 ++++ plugins/Commands/settings.tsx | 61 +++++++++++++++++++++++++++ plugins/Commands/src/commands/gary.ts | 37 ++++++++++++++++ plugins/Commands/src/utils/api.ts | 27 ++++++++++++ 4 files changed, 134 insertions(+) create mode 100644 plugins/Commands/src/commands/gary.ts diff --git a/plugins/Commands/index.ts b/plugins/Commands/index.ts index 15192de..d51f42c 100644 --- a/plugins/Commands/index.ts +++ b/plugins/Commands/index.ts @@ -16,6 +16,7 @@ import { spotifyArtistsCommand, spotifyCoverCommand } from "./src/commands/spotify"; +import { garyCommand } from "./src/commands/gary"; import settings from "./settings"; // Initialize storage with default values @@ -33,6 +34,12 @@ if (!storage.listSettings) { }; } +if (!storage.garySettings) { + storage.garySettings = { + imageSource: "gary", + }; +} + if (!storage.enabledCommands) { storage.enabledCommands = { catfact: true, @@ -49,6 +56,7 @@ if (!storage.enabledCommands) { spotifyAlbum: true, spotifyArtists: true, spotifyCover: true, + gary: true, }; } @@ -68,6 +76,7 @@ const commandMap = { spotifyAlbum: spotifyAlbumCommand, spotifyArtists: spotifyArtistsCommand, spotifyCover: spotifyCoverCommand, + gary: garyCommand, }; // Store registered commands for cleanup diff --git a/plugins/Commands/settings.tsx b/plugins/Commands/settings.tsx index 526dcb3..0bdb7b4 100644 --- a/plugins/Commands/settings.tsx +++ b/plugins/Commands/settings.tsx @@ -29,6 +29,12 @@ if (!storage.listSettings) { }; } +if (!storage.garySettings) { + storage.garySettings = { + imageSource: "gary", + }; +} + if (!storage.enabledCommands) { storage.enabledCommands = { catfact: true, @@ -45,6 +51,7 @@ if (!storage.enabledCommands) { spotifyAlbum: true, spotifyArtists: true, spotifyCover: true, + gary: true, }; } @@ -78,6 +85,11 @@ export default function Settings() { forceRerender(); }; + const handleGarySourceChange = (source: string) => { + storage.garySettings.imageSource = source; + forceRerender(); + }; + return ( + {/* Gary Commands */} + + handleCommandToggle("gary", v)} + /> + { + alerts.showConfirmationAlert({ + title: "Choose Gary Image Source", + content: "Select the source for Gary images:", + confirmText: "Gary API", + confirmColor: "brand", + cancelText: "More Options", + onConfirm: () => handleGarySourceChange("gary"), + onCancel: () => { + alerts.showConfirmationAlert({ + title: "More Image Sources", + content: "Choose another source:", + confirmText: "Cat API", + cancelText: "Even More", + confirmColor: "brand", + onConfirm: () => handleGarySourceChange("catapi"), + onCancel: () => { + alerts.showConfirmationAlert({ + title: "Final Options", + content: "Last two options:", + confirmText: "Minker API", + cancelText: "Goober API", + confirmColor: "brand", + onConfirm: () => handleGarySourceChange("minker"), + onCancel: () => handleGarySourceChange("goober"), + }); + }, + }); + }, + }); + }} + /> + + {/* KonoChan Commands */} + {/* About */} diff --git a/plugins/Commands/src/commands/gary.ts b/plugins/Commands/src/commands/gary.ts new file mode 100644 index 0000000..828b9fe --- /dev/null +++ b/plugins/Commands/src/commands/gary.ts @@ -0,0 +1,37 @@ +import { findByProps } from "@vendetta/metro"; +import { storage } from "@vendetta/plugin"; +import { getGaryUrl } from "../utils/api"; + +const MessageActions = findByProps("sendMessage"); + +export const garyCommand = { + name: "gary", + displayName: "gary", + description: "Send a random Gary image to the channel.", + displayDescription: "Send a random Gary image to the channel.", + options: [], + execute: async (args: any, ctx: any) => { + try { + const source = storage.garySettings?.imageSource || "gary"; + const imageUrl = await getGaryUrl(source); + + if (!imageUrl) { + // Silent fail - no error message + return { type: 4 }; + } + + const fixNonce = Date.now().toString(); + MessageActions.sendMessage(ctx.channel.id, { content: imageUrl }, void 0, { + nonce: fixNonce, + }); + return { type: 4 }; + } catch (error) { + console.error('[Gary] Error:', error); + // Silent fail - no error message in chat + return { type: 4 }; + } + }, + applicationId: "-1", + inputType: 1, + type: 1, +}; diff --git a/plugins/Commands/src/utils/api.ts b/plugins/Commands/src/utils/api.ts index a0fc752..d726171 100644 --- a/plugins/Commands/src/utils/api.ts +++ b/plugins/Commands/src/utils/api.ts @@ -36,3 +36,30 @@ export const getPetPetData = async (image: string) => { const body = await data.json(); return body; }; + +// Gary API function +export const getGaryUrl = async (source: string = "gary"): Promise => { + try { + switch (source) { + case "gary": + const response = await fetch("https://api.garythe.cat/gary"); + const json = await response.json(); + return json.url; + case "goober": + const gooberResponse = await fetch("https://api.garythe.cat/goober"); + const gooberJson = await gooberResponse.json(); + return gooberJson.url; + case "catapi": + const catResponse = await fetch("https://api.thecatapi.com/v1/images/search"); + const catJson = await catResponse.json(); + return catJson[0].url; + case "minker": + return "https://minky.materii.dev/"; + default: + throw new Error("Invalid Gary image source value"); + } + } catch (error) { + console.error(`[Gary API] Error fetching image from ${source}:`, error); + return null; + } +};