GARYYYY
This commit is contained in:
parent
27465fc5f0
commit
16081d8f8d
4 changed files with 134 additions and 0 deletions
|
|
@ -16,6 +16,7 @@ import {
|
||||||
spotifyArtistsCommand,
|
spotifyArtistsCommand,
|
||||||
spotifyCoverCommand
|
spotifyCoverCommand
|
||||||
} from "./src/commands/spotify";
|
} from "./src/commands/spotify";
|
||||||
|
import { garyCommand } from "./src/commands/gary";
|
||||||
import settings from "./settings";
|
import settings from "./settings";
|
||||||
|
|
||||||
// Initialize storage with default values
|
// Initialize storage with default values
|
||||||
|
|
@ -33,6 +34,12 @@ if (!storage.listSettings) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!storage.garySettings) {
|
||||||
|
storage.garySettings = {
|
||||||
|
imageSource: "gary",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (!storage.enabledCommands) {
|
if (!storage.enabledCommands) {
|
||||||
storage.enabledCommands = {
|
storage.enabledCommands = {
|
||||||
catfact: true,
|
catfact: true,
|
||||||
|
|
@ -49,6 +56,7 @@ if (!storage.enabledCommands) {
|
||||||
spotifyAlbum: true,
|
spotifyAlbum: true,
|
||||||
spotifyArtists: true,
|
spotifyArtists: true,
|
||||||
spotifyCover: true,
|
spotifyCover: true,
|
||||||
|
gary: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,6 +76,7 @@ const commandMap = {
|
||||||
spotifyAlbum: spotifyAlbumCommand,
|
spotifyAlbum: spotifyAlbumCommand,
|
||||||
spotifyArtists: spotifyArtistsCommand,
|
spotifyArtists: spotifyArtistsCommand,
|
||||||
spotifyCover: spotifyCoverCommand,
|
spotifyCover: spotifyCoverCommand,
|
||||||
|
gary: garyCommand,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Store registered commands for cleanup
|
// Store registered commands for cleanup
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,12 @@ if (!storage.listSettings) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!storage.garySettings) {
|
||||||
|
storage.garySettings = {
|
||||||
|
imageSource: "gary",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (!storage.enabledCommands) {
|
if (!storage.enabledCommands) {
|
||||||
storage.enabledCommands = {
|
storage.enabledCommands = {
|
||||||
catfact: true,
|
catfact: true,
|
||||||
|
|
@ -45,6 +51,7 @@ if (!storage.enabledCommands) {
|
||||||
spotifyAlbum: true,
|
spotifyAlbum: true,
|
||||||
spotifyArtists: true,
|
spotifyArtists: true,
|
||||||
spotifyCover: true,
|
spotifyCover: true,
|
||||||
|
gary: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,6 +85,11 @@ export default function Settings() {
|
||||||
forceRerender();
|
forceRerender();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleGarySourceChange = (source: string) => {
|
||||||
|
storage.garySettings.imageSource = source;
|
||||||
|
forceRerender();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
<ScrollView
|
<ScrollView
|
||||||
|
|
@ -169,6 +181,54 @@ export default function Settings() {
|
||||||
/>
|
/>
|
||||||
</TableRowGroup>
|
</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 */}
|
{/* KonoChan Commands */}
|
||||||
<TableRowGroup title="KonoChan Commands">
|
<TableRowGroup title="KonoChan Commands">
|
||||||
<TableSwitchRow
|
<TableSwitchRow
|
||||||
|
|
@ -245,6 +305,7 @@ export default function Settings() {
|
||||||
<TableRow label="FirstMessage Command" subLabel="by sapphire" />
|
<TableRow label="FirstMessage Command" subLabel="by sapphire" />
|
||||||
<TableRow label="Sysinfo Command" subLabel="by mugman" />
|
<TableRow label="Sysinfo Command" subLabel="by mugman" />
|
||||||
<TableRow label="Spotify Commands" subLabel="by Kitomanari" />
|
<TableRow label="Spotify Commands" subLabel="by Kitomanari" />
|
||||||
|
<TableRow label="Gary Command" subLabel="by Zach Orange" />
|
||||||
</TableRowGroup>
|
</TableRowGroup>
|
||||||
|
|
||||||
{/* About */}
|
{/* About */}
|
||||||
|
|
|
||||||
37
plugins/Commands/src/commands/gary.ts
Normal file
37
plugins/Commands/src/commands/gary.ts
Normal 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,
|
||||||
|
};
|
||||||
|
|
@ -36,3 +36,30 @@ export const getPetPetData = async (image: string) => {
|
||||||
const body = await data.json();
|
const body = await data.json();
|
||||||
return body;
|
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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue