From 1fba8fdd108b83ae2fdea85b02858b02e8868716 Mon Sep 17 00:00:00 2001 From: kmmiio99o Date: Wed, 1 Oct 2025 16:36:23 +0200 Subject: [PATCH] I'm lazy, used help --- plugins/Commands/settings.tsx | 792 ++++++++++++++------------ plugins/Commands/src/commands/gary.ts | 14 +- 2 files changed, 447 insertions(+), 359 deletions(-) diff --git a/plugins/Commands/settings.tsx b/plugins/Commands/settings.tsx index d128d2a..fff1397 100644 --- a/plugins/Commands/settings.tsx +++ b/plugins/Commands/settings.tsx @@ -10,16 +10,9 @@ import { Forms } from "@vendetta/ui/components"; import { alerts } from "@vendetta/ui"; const { ScrollView } = findByProps("ScrollView"); -const { TableRowGroup, TableSwitchRow, Stack, TableRow } = findByProps( - "TableSwitchRow", - "TableRowGroup", - "Stack", - "TableRow", -); - const { FormRow, FormSwitchRow } = Forms; -// Better Table Row Group Component (inspired by nexpid's styling) +// Better Table Row Group Component function BetterTableRowGroup({ title, icon, @@ -134,112 +127,82 @@ function Header() { ); } -// Credits Page Component -function CreditsPage() { +// Facts Commands Settings Page +function FactsSettingsPage({ forceRerender }: { forceRerender: () => void }) { const styles = stylesheet.createThemedStyleSheet({ container: { flex: 1, backgroundColor: semanticColors.BACKGROUND_PRIMARY, }, - creditItem: { - flexDirection: "row", - alignItems: "center", - paddingVertical: 12, - paddingHorizontal: 16, - backgroundColor: semanticColors.CARD_PRIMARY_BG, - borderRadius: 12, - marginHorizontal: 16, - marginVertical: 4, - }, - avatar: { - width: 40, - height: 40, - borderRadius: 20, - marginRight: 12, - }, - textContainer: { - flex: 1, - }, - commandText: { - fontSize: 16, - fontWeight: "600", - color: semanticColors.TEXT_NORMAL, - }, - authorText: { - fontSize: 14, - color: semanticColors.TEXT_MUTED, - marginTop: 2, - }, }); - const credits = [ - { command: "Facts Commands", author: "jdev082", avatar: "https://github.com/jdev082.png" }, - { command: "List Commands", author: "Kitomanari", avatar: "https://github.com/kitomanari.png" }, - { command: "PetPet Command", author: "wolfieeee", avatar: "https://github.com/wolfieeee.png" }, - { command: "KonoChan Commands", author: "btmc727 & Rico040", avatar: "https://github.com/btmc727.png" }, - { command: "FirstMessage Command", author: "sapphire", avatar: "https://github.com/sapphiredevs.png" }, - { command: "Sysinfo Command", author: "mugman", avatar: "https://github.com/mugmandev.png" }, - { command: "Spotify Commands", author: "Kitomanari", avatar: "https://github.com/kitomanari.png" }, - { command: "Gary Command", author: "Zach Orange", avatar: "https://github.com/zachorange.png" }, - ]; - return ( - - - - Thanks to all the amazing developers who contributed to this plugin collection! - + + + } + value={storage.factSettings?.sendAsReply ?? true} + onValueChange={(v: boolean) => { + storage.factSettings.sendAsReply = v; + forceRerender(); + }} + /> + } + value={storage.factSettings?.includeCitation ?? false} + onValueChange={(v: boolean) => { + storage.factSettings.includeCitation = v; + forceRerender(); + }} + /> - {credits.map((credit, index) => ( - - - - {credit.command} - by {credit.author} - - - ))} - - - - Commands Plugin Collection{'\n'} - Version 1.0.0{'\n'} - Made with ❤️ for the community - + + } + value={storage.enabledCommands?.catfact ?? true} + onValueChange={(v) => { + storage.enabledCommands.catfact = v; + storage.pendingRestart = true; + forceRerender(); + }} + /> + } + value={storage.enabledCommands?.dogfact ?? true} + onValueChange={(v) => { + storage.enabledCommands.dogfact = v; + storage.pendingRestart = true; + forceRerender(); + }} + /> + } + value={storage.enabledCommands?.useless ?? true} + onValueChange={(v) => { + storage.enabledCommands.useless = v; + storage.pendingRestart = true; + forceRerender(); + }} + /> ); } -// Gary API Settings Page Component +// Gary API Settings Page function GaryAPIPage({ forceRerender }: { forceRerender: () => void }) { const styles = stylesheet.createThemedStyleSheet({ container: { @@ -257,7 +220,7 @@ function GaryAPIPage({ forceRerender }: { forceRerender: () => void }) { marginVertical: 4, }, selectedOption: { - backgroundColor: semanticColors.BRAND_500_ALPHA, + backgroundColor: semanticColors.BRAND_500_ALPHA || `${semanticColors.BRAND_500}20`, borderColor: semanticColors.BRAND_500, borderWidth: 2, }, @@ -300,6 +263,18 @@ function GaryAPIPage({ forceRerender }: { forceRerender: () => void }) { selectedText: { color: semanticColors.BRAND_500, }, + infoText: { + fontSize: 14, + color: semanticColors.TEXT_MUTED, + marginBottom: 16, + textAlign: "center", + }, + currentText: { + fontSize: 14, + color: semanticColors.TEXT_NORMAL, + textAlign: "center", + fontWeight: "600", + }, }); const options = [ @@ -333,22 +308,23 @@ function GaryAPIPage({ forceRerender }: { forceRerender: () => void }) { return ( - - - + + + } + value={storage.enabledCommands?.gary ?? true} + onValueChange={(v) => { + storage.enabledCommands.gary = v; + storage.pendingRestart = true; + forceRerender(); + }} + /> + + + + Choose which API the /gary command should use to fetch images. @@ -363,6 +339,7 @@ function GaryAPIPage({ forceRerender }: { forceRerender: () => void }) { isSelected ? styles.selectedOption : styles.normalOption, ]} onPress={() => { + console.log(`[Settings] Changing Gary API to: ${option.value}`); storage.garySettings.imageSource = option.value; forceRerender(); }} @@ -397,17 +374,8 @@ function GaryAPIPage({ forceRerender }: { forceRerender: () => void }) { ); })} - - + + Currently using: { currentSource === "gary" ? "Gary API" : currentSource === "catapi" ? "Cat API" : @@ -421,6 +389,312 @@ function GaryAPIPage({ forceRerender }: { forceRerender: () => void }) { ); } +// List Commands Settings Page +function ListSettingsPage({ forceRerender }: { forceRerender: () => void }) { + const styles = stylesheet.createThemedStyleSheet({ + container: { + flex: 1, + backgroundColor: semanticColors.BACKGROUND_PRIMARY, + }, + }); + + return ( + + + + } + value={storage.listSettings?.pluginListAlwaysDetailed ?? false} + onValueChange={(v: boolean) => { + storage.listSettings.pluginListAlwaysDetailed = v; + forceRerender(); + }} + /> + } + value={storage.listSettings?.themeListAlwaysDetailed ?? false} + onValueChange={(v: boolean) => { + storage.listSettings.themeListAlwaysDetailed = v; + forceRerender(); + }} + /> + + + + } + value={storage.enabledCommands?.pluginList ?? true} + onValueChange={(v) => { + storage.enabledCommands.pluginList = v; + storage.pendingRestart = true; + forceRerender(); + }} + /> + } + value={storage.enabledCommands?.themeList ?? true} + onValueChange={(v) => { + storage.enabledCommands.themeList = v; + storage.pendingRestart = true; + forceRerender(); + }} + /> + + + + ); +} + +// Image Commands Settings Page +function ImageSettingsPage({ forceRerender }: { forceRerender: () => void }) { + const styles = stylesheet.createThemedStyleSheet({ + container: { + flex: 1, + backgroundColor: semanticColors.BACKGROUND_PRIMARY, + }, + }); + + return ( + + + + } + value={storage.enabledCommands?.petpet ?? true} + onValueChange={(v) => { + storage.enabledCommands.petpet = v; + storage.pendingRestart = true; + forceRerender(); + }} + /> + + + + } + value={storage.enabledCommands?.konoself ?? true} + onValueChange={(v) => { + storage.enabledCommands.konoself = v; + storage.pendingRestart = true; + forceRerender(); + }} + /> + } + value={storage.enabledCommands?.konosend ?? true} + onValueChange={(v) => { + storage.enabledCommands.konosend = v; + storage.pendingRestart = true; + forceRerender(); + }} + /> + + + + ); +} + +// Other Commands Settings Page +function OtherSettingsPage({ forceRerender }: { forceRerender: () => void }) { + const styles = stylesheet.createThemedStyleSheet({ + container: { + flex: 1, + backgroundColor: semanticColors.BACKGROUND_PRIMARY, + }, + }); + + return ( + + + + } + value={storage.enabledCommands?.firstmessage ?? true} + onValueChange={(v) => { + storage.enabledCommands.firstmessage = v; + storage.pendingRestart = true; + forceRerender(); + }} + /> + + + + } + value={storage.enabledCommands?.sysinfo ?? true} + onValueChange={(v) => { + storage.enabledCommands.sysinfo = v; + storage.pendingRestart = true; + forceRerender(); + }} + /> + + + + } + value={storage.enabledCommands?.spotifyTrack ?? true} + onValueChange={(v) => { + storage.enabledCommands.spotifyTrack = v; + storage.pendingRestart = true; + forceRerender(); + }} + /> + } + value={storage.enabledCommands?.spotifyAlbum ?? true} + onValueChange={(v) => { + storage.enabledCommands.spotifyAlbum = v; + storage.pendingRestart = true; + forceRerender(); + }} + /> + } + value={storage.enabledCommands?.spotifyArtists ?? true} + onValueChange={(v) => { + storage.enabledCommands.spotifyArtists = v; + storage.pendingRestart = true; + forceRerender(); + }} + /> + } + value={storage.enabledCommands?.spotifyCover ?? true} + onValueChange={(v) => { + storage.enabledCommands.spotifyCover = v; + storage.pendingRestart = true; + forceRerender(); + }} + /> + + + + ); +} + +// Credits Page +function CreditsPage() { + const styles = stylesheet.createThemedStyleSheet({ + container: { + flex: 1, + backgroundColor: semanticColors.BACKGROUND_PRIMARY, + }, + creditItem: { + flexDirection: "row", + alignItems: "center", + paddingVertical: 12, + paddingHorizontal: 16, + backgroundColor: semanticColors.CARD_PRIMARY_BG, + borderRadius: 12, + marginHorizontal: 16, + marginVertical: 4, + }, + avatar: { + width: 40, + height: 40, + borderRadius: 20, + marginRight: 12, + }, + textContainer: { + flex: 1, + }, + commandText: { + fontSize: 16, + fontWeight: "600", + color: semanticColors.TEXT_NORMAL, + }, + authorText: { + fontSize: 14, + color: semanticColors.TEXT_MUTED, + marginTop: 2, + }, + infoText: { + fontSize: 14, + color: semanticColors.TEXT_MUTED, + marginBottom: 16, + textAlign: "center", + }, + versionText: { + fontSize: 14, + color: semanticColors.TEXT_NORMAL, + textAlign: "center", + fontWeight: "600", + lineHeight: 20, + }, + }); + + const credits = [ + { command: "Facts Commands", author: "jdev082", avatar: "https://github.com/jdev082.png" }, + { command: "List Commands", author: "Kitomanari", avatar: "https://github.com/kitomanari.png" }, + { command: "PetPet Command", author: "wolfieeee", avatar: "https://github.com/wolfieeee.png" }, + { command: "KonoChan Commands", author: "btmc727 & Rico040", avatar: "https://github.com/btmc727.png" }, + { command: "FirstMessage Command", author: "sapphire", avatar: "https://github.com/sapphiredevs.png" }, + { command: "Sysinfo Command", author: "mugman", avatar: "https://github.com/mugmandev.png" }, + { command: "Spotify Commands", author: "Kitomanari", avatar: "https://github.com/kitomanari.png" }, + { command: "Gary Command", author: "Zach Orange", avatar: "https://github.com/zachorange.png" }, + ]; + + return ( + + + + + Thanks to all the amazing developers who contributed to this plugin collection! + + + + {credits.map((credit, index) => ( + + + + {credit.command} + by {credit.author} + + + ))} + + + + Commands Plugin Collection{'\n'} + Version 1.0.0{'\n'} + Made with ❤️ for the community + + + + + ); +} + // Initialize storage with default values if (!storage.factSettings) { storage.factSettings = { @@ -477,9 +751,6 @@ export default function Settings() { flex: 1, backgroundColor: semanticColors.BACKGROUND_PRIMARY, }, - spacing: { - height: 16, - }, }); // Check for pending restart when unmounting @@ -498,23 +769,10 @@ export default function Settings() { }; }, []); - const handleCommandToggle = (commandName: string, value: boolean) => { - storage.enabledCommands[commandName] = value; - storage.pendingRestart = true; - forceRerender(); - }; - - const navigateToCredits = () => { + const navigateToPage = (title: string, component: React.ComponentType) => { navigation.push("VendettaCustomPage", { - title: "Credits", - render: () => , - }); - }; - - const navigateToGaryAPI = () => { - navigation.push("VendettaCustomPage", { - title: "Gary API Settings", - render: () => , + title, + render: () => React.createElement(component, { forceRerender }), }); }; @@ -526,233 +784,59 @@ export default function Settings() { showsVerticalScrollIndicator={false} >
- - {/* Facts Commands */} - - } - value={storage.factSettings?.sendAsReply ?? true} - onValueChange={(v: boolean) => { - storage.factSettings.sendAsReply = v; - forceRerender(); - }} - /> - } - value={storage.factSettings?.includeCitation ?? false} - onValueChange={(v: boolean) => { - storage.factSettings.includeCitation = v; - forceRerender(); - }} - /> - } - value={storage.enabledCommands?.catfact ?? true} - onValueChange={(v) => handleCommandToggle("catfact", v)} - /> - } - value={storage.enabledCommands?.dogfact ?? true} - onValueChange={(v) => handleCommandToggle("dogfact", v)} - /> - } - value={storage.enabledCommands?.useless ?? true} - onValueChange={(v) => handleCommandToggle("useless", v)} - /> - - {/* List Commands */} - - } - value={storage.listSettings?.pluginListAlwaysDetailed ?? false} - onValueChange={(v: boolean) => { - storage.listSettings.pluginListAlwaysDetailed = v; - forceRerender(); - }} - /> - } - value={storage.listSettings?.themeListAlwaysDetailed ?? false} - onValueChange={(v: boolean) => { - storage.listSettings.themeListAlwaysDetailed = v; - forceRerender(); - }} - /> - } - value={storage.enabledCommands?.pluginList ?? true} - onValueChange={(v) => handleCommandToggle("pluginList", v)} - /> - } - value={storage.enabledCommands?.themeList ?? true} - onValueChange={(v) => handleCommandToggle("themeList", v)} - /> - - - {/* Image Commands */} - - } - value={storage.enabledCommands?.petpet ?? true} - onValueChange={(v) => handleCommandToggle("petpet", v)} - /> - - - {/* Gary Commands */} - - } - value={storage.enabledCommands?.gary ?? true} - onValueChange={(v) => handleCommandToggle("gary", v)} + {/* Command Categories */} + + } + trailing={} + onPress={() => navigateToPage("Facts Commands", FactsSettingsPage)} /> } + trailing={} + onPress={() => navigateToPage("List Commands", ListSettingsPage)} + /> + } + trailing={} + onPress={() => navigateToPage("Image Commands", ImageSettingsPage)} + /> + } + leading={} trailing={} - onPress={navigateToGaryAPI} + onPress={() => navigateToPage("Gary Commands", GaryAPIPage)} + /> + } + trailing={} + onPress={() => navigateToPage("Other Commands", OtherSettingsPage)} /> - {/* KonoChan Commands */} - - } - value={storage.enabledCommands?.konoself ?? true} - onValueChange={(v) => handleCommandToggle("konoself", v)} - /> - } - value={storage.enabledCommands?.konosend ?? true} - onValueChange={(v) => handleCommandToggle("konosend", v)} - /> - - - {/* Message Commands */} - - } - value={storage.enabledCommands?.firstmessage ?? true} - onValueChange={(v) => handleCommandToggle("firstmessage", v)} - /> - - - {/* System Commands */} - - } - value={storage.enabledCommands?.sysinfo ?? true} - onValueChange={(v) => handleCommandToggle("sysinfo", v)} - /> - - - {/* Spotify Commands */} - - } - value={storage.enabledCommands?.spotifyTrack ?? true} - onValueChange={(v) => handleCommandToggle("spotifyTrack", v)} - /> - } - value={storage.enabledCommands?.spotifyAlbum ?? true} - onValueChange={(v) => handleCommandToggle("spotifyAlbum", v)} - /> - } - value={storage.enabledCommands?.spotifyArtists ?? true} - onValueChange={(v) => handleCommandToggle("spotifyArtists", v)} - /> - } - value={storage.enabledCommands?.spotifyCover ?? true} - onValueChange={(v) => handleCommandToggle("spotifyCover", v)} - /> - - - {/* Navigation Pages */} - + {/* More Options */} + } trailing={} - onPress={navigateToCredits} + onPress={() => navigateToPage("Credits", CreditsPage)} /> - - ); diff --git a/plugins/Commands/src/commands/gary.ts b/plugins/Commands/src/commands/gary.ts index ea44199..fea00ce 100644 --- a/plugins/Commands/src/commands/gary.ts +++ b/plugins/Commands/src/commands/gary.ts @@ -12,19 +12,23 @@ export const garyCommand = { options: [], execute: async (args: any, ctx: any) => { try { - // 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"; + // Ensure garySettings exists and get the source + if (!storage.garySettings) { + storage.garySettings = { imageSource: "gary" }; + } + + const source = storage.garySettings.imageSource || "gary"; + console.log(`[Gary Command] Using image source: ${source}`); // Debug log const imageUrl = await getGaryUrl(source); if (!imageUrl) { + console.log("[Gary Command] No image URL received"); // Silent fail - no error message return { type: 4 }; } + console.log(`[Gary Command] Sending image: ${imageUrl}`); // Debug log const fixNonce = Date.now().toString(); MessageActions.sendMessage(ctx.channel.id, { content: imageUrl }, void 0, { nonce: fixNonce,