import { plugin } from "@vendetta";
import { storage } from "@vendetta/plugin";
import { useProxy } from "@vendetta/storage";
import { React, ReactNative as RN, stylesheet } from "@vendetta/metro/common";
import { findByProps } from "@vendetta/metro";
import { NavigationNative } from "@vendetta/metro/common";
import { semanticColors } from "@vendetta/ui";
import { getAssetIDByName } from "@vendetta/ui/assets";
import { Forms } from "@vendetta/ui/components";
import { alerts } from "@vendetta/ui";
const { ScrollView } = findByProps("ScrollView");
const { FormRow, FormSwitchRow } = Forms;
// Better Table Row Group Component
function BetterTableRowGroup({
title,
icon,
children,
padding = false,
}: React.PropsWithChildren<{
title?: string;
icon?: number;
padding?: boolean;
}>) {
const styles = stylesheet.createThemedStyleSheet({
main: {
backgroundColor: semanticColors.CARD_PRIMARY_BG,
borderColor: semanticColors.BORDER_FAINT,
borderWidth: 1,
borderRadius: 16,
overflow: "hidden",
flex: 1,
},
titleContainer: {
marginBottom: 8,
marginHorizontal: 0,
marginTop: 8,
gap: 4,
flexDirection: "row",
alignItems: "center",
},
icon: {
width: 16,
height: 16,
marginTop: 1.5,
tintColor: semanticColors.TEXT_MUTED,
},
titleText: {
fontSize: 14,
fontWeight: "600",
color: semanticColors.TEXT_MUTED,
},
});
return (
{title && (
{icon && (
)}
{title.toUpperCase()}
)}
{padding ? (
{children}
) : children}
);
}
// Header Component
function Header() {
const styles = stylesheet.createThemedStyleSheet({
container: {
flexDirection: "column",
alignItems: "center",
paddingVertical: 24,
paddingHorizontal: 16,
},
title: {
fontSize: 28,
fontWeight: "700",
color: semanticColors.TEXT_NORMAL,
marginBottom: 4,
},
subtitle: {
fontSize: 16,
fontWeight: "500",
color: semanticColors.TEXT_MUTED,
},
iconContainer: {
backgroundColor: semanticColors.BACKGROUND_SECONDARY,
borderRadius: 16,
padding: 12,
marginBottom: 16,
},
icon: {
width: 32,
height: 32,
tintColor: semanticColors.TEXT_NORMAL,
},
});
return (
Commands
A collection of useful commands
);
}
// Facts Commands Settings Page
function FactsSettingsPage({ forceRerender }: { forceRerender: () => void }) {
const styles = stylesheet.createThemedStyleSheet({
container: {
flex: 1,
backgroundColor: semanticColors.BACKGROUND_PRIMARY,
},
});
return (
}
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) => {
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
function GaryAPIPage({ forceRerender }: { forceRerender: () => void }) {
useProxy(storage);
const styles = stylesheet.createThemedStyleSheet({
container: {
flex: 1,
backgroundColor: semanticColors.BACKGROUND_PRIMARY,
},
infoText: {
fontSize: 14,
color: semanticColors.TEXT_MUTED,
marginBottom: 16,
textAlign: "center",
},
currentText: {
fontSize: 14,
color: semanticColors.TEXT_NORMAL,
textAlign: "center",
fontWeight: "600",
},
});
const currentSource = storage.garySettings?.imageSource || "gary";
const handleSourceChange = (newSource: string) => {
console.log(`[Gary Settings] Changing from ${currentSource} to ${newSource}`);
storage.garySettings.imageSource = newSource;
forceRerender();
};
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.
}
value={currentSource === "gary"}
onValueChange={(v) => v && handleSourceChange("gary")}
/>
}
value={currentSource === "catapi"}
onValueChange={(v) => v && handleSourceChange("catapi")}
/>
}
value={currentSource === "minker"}
onValueChange={(v) => v && handleSourceChange("minker")}
/>
}
value={currentSource === "goober"}
onValueChange={(v) => v && handleSourceChange("goober")}
/>
Currently using: {
currentSource === "gary" ? "Gary API" :
currentSource === "catapi" ? "Cat API" :
currentSource === "minker" ? "Minker API" :
currentSource === "goober" ? "Goober API" : "Gary API"
}
);
}
// 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();
}}
/>
);
}
// Spotify Commands Settings Page
function SpotifySettingsPage({ forceRerender }: { forceRerender: () => void }) {
const styles = stylesheet.createThemedStyleSheet({
container: {
flex: 1,
backgroundColor: semanticColors.BACKGROUND_PRIMARY,
},
infoText: {
fontSize: 14,
color: semanticColors.TEXT_MUTED,
textAlign: "center",
lineHeight: 20,
},
});
return (
}
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();
}}
/>
These commands allow you to share your current Spotify activity in Discord. Make sure you have Spotify connected to Discord for these commands to work properly.
);
}
// 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();
}}
/>
);
}
// 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 = {
sendAsReply: true,
includeCitation: false,
};
}
if (!storage.listSettings) {
storage.listSettings = {
pluginListAlwaysDetailed: false,
themeListAlwaysDetailed: false,
};
}
if (!storage.garySettings) {
storage.garySettings = {
imageSource: "gary",
};
}
if (!storage.enabledCommands) {
storage.enabledCommands = {
catfact: true,
dogfact: true,
useless: true,
petpet: true,
pluginList: true,
themeList: true,
konoself: true,
konosend: true,
firstmessage: true,
sysinfo: true,
spotifyTrack: true,
spotifyAlbum: true,
spotifyArtists: true,
spotifyCover: true,
gary: true,
};
}
if (!storage.pendingRestart) {
storage.pendingRestart = false;
}
// Main Settings Component
export default function Settings() {
useProxy(storage);
const [rerender, forceRerender] = React.useReducer((x) => x + 1, 0);
const navigation = NavigationNative.useNavigation();
const styles = stylesheet.createThemedStyleSheet({
container: {
flex: 1,
backgroundColor: semanticColors.BACKGROUND_PRIMARY,
},
});
// Check for pending restart when unmounting
React.useEffect(() => {
return () => {
if (storage.pendingRestart) {
storage.pendingRestart = false;
alerts.showConfirmationAlert({
title: "Restart Required",
content:
"You have made changes to commands. Please restart Discord to apply these changes.",
confirmText: "Okay",
cancelText: null,
});
}
};
}, []);
const navigateToPage = (title: string, component: React.ComponentType) => {
navigation.push("VendettaCustomPage", {
title,
render: () => React.createElement(component, { forceRerender }),
});
};
return (
{/* Command Categories */}
}
trailing={}
onPress={() => navigateToPage("Facts Commands", FactsSettingsPage)}
/>
}
trailing={}
onPress={() => navigateToPage("List Commands", ListSettingsPage)}
/>
}
trailing={}
onPress={() => navigateToPage("Image Commands", ImageSettingsPage)}
/>
}
trailing={}
onPress={() => navigateToPage("Gary Commands", GaryAPIPage)}
/>
}
trailing={}
onPress={() => navigateToPage("Spotify Commands", SpotifySettingsPage)}
/>
}
trailing={}
onPress={() => navigateToPage("Other Commands", OtherSettingsPage)}
/>
{/* More Options */}
}
trailing={}
onPress={() => navigateToPage("Credits", CreditsPage)}
/>
);
}