This commit is contained in:
kmmiio99o 2025-10-01 15:41:01 +02:00
parent 27465fc5f0
commit 16081d8f8d
4 changed files with 134 additions and 0 deletions

View file

@ -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

View file

@ -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 (
<View style={{ flex: 1 }}>
<ScrollView
@ -169,6 +181,54 @@ export default function Settings() {
/>
</TableRowGroup>
{/* Gary Commands */}
<TableRowGroup title="Gary Commands">
<TableSwitchRow
label="/gary"
subLabel="Send random Gary images to channel"
value={storage.enabledCommands?.gary ?? true}
onValueChange={(v) => handleCommandToggle("gary", v)}
/>
<TableRow
label="Gary Image Source"
subLabel={`Current: ${storage.garySettings?.imageSource === "gary" ? "Gary API" :
storage.garySettings?.imageSource === "catapi" ? "Cat API" :
storage.garySettings?.imageSource === "minker" ? "Minker API" :
storage.garySettings?.imageSource === "goober" ? "Goober API" : "Gary API"}`}
onPress={() => {
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"),
});
},
});
},
});
}}
/>
</TableRowGroup>
{/* KonoChan Commands */}
<TableRowGroup title="KonoChan Commands">
<TableSwitchRow
@ -245,6 +305,7 @@ export default function Settings() {
<TableRow label="FirstMessage Command" subLabel="by sapphire" />
<TableRow label="Sysinfo Command" subLabel="by mugman" />
<TableRow label="Spotify Commands" subLabel="by Kitomanari" />
<TableRow label="Gary Command" subLabel="by Zach Orange" />
</TableRowGroup>
{/* About */}

View file

@ -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,
};

View file

@ -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<string | null> => {
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;
}
};