2025-09-27 20:10:37 +02:00
|
|
|
import { plugin } from "@vendetta";
|
2025-09-27 20:15:20 +02:00
|
|
|
import { storage } from "@vendetta/plugin";
|
|
|
|
|
import { useProxy } from "@vendetta/storage";
|
2025-09-27 19:17:06 +02:00
|
|
|
import { getAssetIDByName } from "@vendetta/ui/assets";
|
2025-09-27 20:10:37 +02:00
|
|
|
import { React } from "@vendetta/metro/common";
|
|
|
|
|
import { findByProps } from "@vendetta/metro";
|
2025-09-27 20:15:20 +02:00
|
|
|
import { View } from "react-native";
|
2025-09-27 20:30:21 +02:00
|
|
|
import { alerts } from "@vendetta/ui";
|
2025-09-27 19:17:06 +02:00
|
|
|
|
2025-09-27 20:10:37 +02:00
|
|
|
const { ScrollView } = findByProps("ScrollView");
|
2025-09-27 20:44:51 +02:00
|
|
|
const { TableRowGroup, TableSwitchRow, Stack, TableRow } = findByProps(
|
2025-09-27 20:10:37 +02:00
|
|
|
"TableSwitchRow",
|
|
|
|
|
"TableRowGroup",
|
|
|
|
|
"Stack",
|
2025-09-27 20:44:51 +02:00
|
|
|
"TableRow",
|
2025-09-27 20:10:37 +02:00
|
|
|
);
|
2025-09-27 19:40:15 +02:00
|
|
|
|
2025-09-27 20:15:20 +02:00
|
|
|
// Initialize default settings if not exist
|
|
|
|
|
if (!storage.factSettings) {
|
|
|
|
|
storage.factSettings = {
|
|
|
|
|
sendAsReply: true,
|
|
|
|
|
includeCitation: false,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!storage.listSettings) {
|
|
|
|
|
storage.listSettings = {
|
|
|
|
|
pluginListAlwaysDetailed: false,
|
|
|
|
|
themeListAlwaysDetailed: false,
|
|
|
|
|
};
|
|
|
|
|
}
|
2025-09-27 19:17:06 +02:00
|
|
|
|
2025-09-27 20:30:21 +02:00
|
|
|
if (!storage.enabledCommands) {
|
|
|
|
|
storage.enabledCommands = {
|
|
|
|
|
catfact: true,
|
|
|
|
|
dogfact: true,
|
|
|
|
|
useless: true,
|
|
|
|
|
petpet: true,
|
|
|
|
|
pluginList: true,
|
|
|
|
|
themeList: true,
|
|
|
|
|
konoself: true,
|
|
|
|
|
konosend: true,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-27 20:44:51 +02:00
|
|
|
if (!storage.pendingRestart) {
|
|
|
|
|
storage.pendingRestart = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Credits = {
|
|
|
|
|
PETPET: "wolfieeee",
|
|
|
|
|
FACTS: "jdev082",
|
|
|
|
|
LISTS: "Kitomanari",
|
|
|
|
|
KONOCHAN: ["btmc727", "Rico040"],
|
2025-09-27 20:30:21 +02:00
|
|
|
};
|
|
|
|
|
|
2025-09-27 20:10:37 +02:00
|
|
|
export default function Settings() {
|
2025-09-27 20:15:20 +02:00
|
|
|
useProxy(storage);
|
|
|
|
|
const [rerender, forceRerender] = React.useReducer((x) => x + 1, 0);
|
2025-09-27 19:17:06 +02:00
|
|
|
|
2025-09-27 20:44:51 +02:00
|
|
|
// Check for changes when component unmounts
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
|
return () => {
|
|
|
|
|
if (storage.pendingRestart) {
|
|
|
|
|
alerts.showConfirmationAlert({
|
|
|
|
|
title: "Restart Required",
|
|
|
|
|
content:
|
|
|
|
|
"Command changes require Discord to restart. Would you like to restart now?",
|
|
|
|
|
confirmText: "Restart",
|
|
|
|
|
cancelText: "Later",
|
|
|
|
|
confirmColor: "brand",
|
|
|
|
|
onConfirm: () => {
|
|
|
|
|
window.enmity.plugins.reload("vendetta");
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}, []);
|
|
|
|
|
|
2025-09-27 20:30:21 +02:00
|
|
|
const handleCommandToggle = (commandName: string, value: boolean) => {
|
2025-09-27 20:44:51 +02:00
|
|
|
storage.enabledCommands[commandName] = value;
|
|
|
|
|
storage.pendingRestart = true;
|
2025-09-27 20:30:21 +02:00
|
|
|
forceRerender();
|
|
|
|
|
};
|
|
|
|
|
|
2025-09-27 19:40:15 +02:00
|
|
|
return (
|
2025-09-27 20:15:20 +02:00
|
|
|
<View style={{ flex: 1 }}>
|
|
|
|
|
<ScrollView style={{ flex: 1 }}>
|
|
|
|
|
<Stack spacing={8}>
|
2025-09-27 20:30:21 +02:00
|
|
|
{/* Facts Commands */}
|
2025-09-27 20:22:48 +02:00
|
|
|
<TableRowGroup title="Facts Commands">
|
2025-09-27 20:15:20 +02:00
|
|
|
<TableSwitchRow
|
|
|
|
|
label="Send as Reply"
|
|
|
|
|
subLabel="Send facts as a reply to the command message"
|
|
|
|
|
icon={getAssetIDByName("ic_reply_24px")}
|
|
|
|
|
value={storage.factSettings.sendAsReply}
|
|
|
|
|
onValueChange={(v: boolean) => {
|
|
|
|
|
storage.factSettings.sendAsReply = v;
|
|
|
|
|
forceRerender();
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<TableSwitchRow
|
|
|
|
|
label="Include Source Citation"
|
|
|
|
|
subLabel="Include the source of facts when available"
|
|
|
|
|
icon={getAssetIDByName("ic_info")}
|
|
|
|
|
value={storage.factSettings.includeCitation}
|
|
|
|
|
onValueChange={(v: boolean) => {
|
|
|
|
|
storage.factSettings.includeCitation = v;
|
|
|
|
|
forceRerender();
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2025-09-27 20:44:51 +02:00
|
|
|
<TableRow
|
|
|
|
|
label="Credits"
|
|
|
|
|
subLabel={`Facts commands by ${Credits.FACTS}`}
|
|
|
|
|
icon={getAssetIDByName("ic_info")}
|
|
|
|
|
/>
|
2025-09-27 20:22:48 +02:00
|
|
|
<TableSwitchRow
|
|
|
|
|
label="/catfact"
|
|
|
|
|
subLabel="Get random cat facts"
|
|
|
|
|
icon={getAssetIDByName("ic_info")}
|
2025-09-27 20:30:21 +02:00
|
|
|
value={storage.enabledCommands.catfact}
|
|
|
|
|
onValueChange={(v) => handleCommandToggle("catfact", v)}
|
2025-09-27 20:22:48 +02:00
|
|
|
/>
|
|
|
|
|
<TableSwitchRow
|
|
|
|
|
label="/dogfact"
|
|
|
|
|
subLabel="Get random dog facts"
|
|
|
|
|
icon={getAssetIDByName("ic_info")}
|
2025-09-27 20:30:21 +02:00
|
|
|
value={storage.enabledCommands.dogfact}
|
|
|
|
|
onValueChange={(v) => handleCommandToggle("dogfact", v)}
|
2025-09-27 20:22:48 +02:00
|
|
|
/>
|
|
|
|
|
<TableSwitchRow
|
|
|
|
|
label="/useless"
|
|
|
|
|
subLabel="Get random useless facts"
|
|
|
|
|
icon={getAssetIDByName("ic_info")}
|
2025-09-27 20:30:21 +02:00
|
|
|
value={storage.enabledCommands.useless}
|
|
|
|
|
onValueChange={(v) => handleCommandToggle("useless", v)}
|
2025-09-27 20:22:48 +02:00
|
|
|
/>
|
2025-09-27 20:15:20 +02:00
|
|
|
</TableRowGroup>
|
2025-09-27 19:17:06 +02:00
|
|
|
|
2025-09-27 20:44:51 +02:00
|
|
|
{/* List Commands */}
|
2025-09-27 20:22:48 +02:00
|
|
|
<TableRowGroup title="List Commands">
|
2025-09-27 20:15:20 +02:00
|
|
|
<TableSwitchRow
|
2025-09-27 20:22:48 +02:00
|
|
|
label="Always Send Detailed Plugin List"
|
2025-09-27 20:15:20 +02:00
|
|
|
subLabel="Always use detailed mode when listing plugins"
|
|
|
|
|
icon={getAssetIDByName("ic_message_copy")}
|
|
|
|
|
value={storage.listSettings.pluginListAlwaysDetailed}
|
|
|
|
|
onValueChange={(v: boolean) => {
|
|
|
|
|
storage.listSettings.pluginListAlwaysDetailed = v;
|
|
|
|
|
forceRerender();
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<TableSwitchRow
|
2025-09-27 20:22:48 +02:00
|
|
|
label="Always Send Detailed Theme List"
|
2025-09-27 20:15:20 +02:00
|
|
|
subLabel="Always use detailed mode when listing themes"
|
|
|
|
|
icon={getAssetIDByName("ic_theme")}
|
|
|
|
|
value={storage.listSettings.themeListAlwaysDetailed}
|
|
|
|
|
onValueChange={(v: boolean) => {
|
|
|
|
|
storage.listSettings.themeListAlwaysDetailed = v;
|
|
|
|
|
forceRerender();
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2025-09-27 20:44:51 +02:00
|
|
|
<TableRow
|
|
|
|
|
label="Credits"
|
|
|
|
|
subLabel={`List commands by ${Credits.LISTS}`}
|
|
|
|
|
icon={getAssetIDByName("ic_info")}
|
|
|
|
|
/>
|
2025-09-27 20:15:20 +02:00
|
|
|
<TableSwitchRow
|
2025-09-27 20:22:48 +02:00
|
|
|
label="/plugin-list"
|
|
|
|
|
subLabel="List all installed plugins"
|
|
|
|
|
icon={getAssetIDByName("ic_plugins")}
|
2025-09-27 20:30:21 +02:00
|
|
|
value={storage.enabledCommands.pluginList}
|
|
|
|
|
onValueChange={(v) => handleCommandToggle("pluginList", v)}
|
2025-09-27 20:15:20 +02:00
|
|
|
/>
|
|
|
|
|
<TableSwitchRow
|
2025-09-27 20:22:48 +02:00
|
|
|
label="/theme-list"
|
|
|
|
|
subLabel="List all installed themes"
|
|
|
|
|
icon={getAssetIDByName("ic_theme")}
|
2025-09-27 20:30:21 +02:00
|
|
|
value={storage.enabledCommands.themeList}
|
|
|
|
|
onValueChange={(v) => handleCommandToggle("themeList", v)}
|
2025-09-27 20:15:20 +02:00
|
|
|
/>
|
2025-09-27 20:22:48 +02:00
|
|
|
</TableRowGroup>
|
|
|
|
|
|
|
|
|
|
{/* Image Commands */}
|
|
|
|
|
<TableRowGroup title="Image Commands">
|
2025-09-27 20:44:51 +02:00
|
|
|
<TableRow
|
|
|
|
|
label="Credits"
|
|
|
|
|
subLabel={`PetPet command by ${Credits.PETPET}`}
|
|
|
|
|
icon={getAssetIDByName("ic_info")}
|
|
|
|
|
/>
|
2025-09-27 20:15:20 +02:00
|
|
|
<TableSwitchRow
|
|
|
|
|
label="/petpet"
|
|
|
|
|
subLabel="Create pet-pet GIF of a user"
|
|
|
|
|
icon={getAssetIDByName("ic_image")}
|
2025-09-27 20:30:21 +02:00
|
|
|
value={storage.enabledCommands.petpet}
|
|
|
|
|
onValueChange={(v) => handleCommandToggle("petpet", v)}
|
2025-09-27 20:15:20 +02:00
|
|
|
/>
|
2025-09-27 20:22:48 +02:00
|
|
|
</TableRowGroup>
|
|
|
|
|
|
|
|
|
|
{/* KonoChan Commands */}
|
|
|
|
|
<TableRowGroup title="KonoChan Commands">
|
2025-09-27 20:44:51 +02:00
|
|
|
<TableRow
|
|
|
|
|
label="Credits"
|
|
|
|
|
subLabel={`KonoChan commands by ${Credits.KONOCHAN.join(" & ")}`}
|
|
|
|
|
icon={getAssetIDByName("ic_info")}
|
|
|
|
|
/>
|
2025-09-27 20:15:20 +02:00
|
|
|
<TableSwitchRow
|
2025-09-27 20:22:48 +02:00
|
|
|
label="/konoself"
|
|
|
|
|
subLabel="Get random image from KonoChan (private)"
|
|
|
|
|
icon={getAssetIDByName("ic_image")}
|
2025-09-27 20:30:21 +02:00
|
|
|
value={storage.enabledCommands.konoself}
|
|
|
|
|
onValueChange={(v) => handleCommandToggle("konoself", v)}
|
2025-09-27 20:15:20 +02:00
|
|
|
/>
|
|
|
|
|
<TableSwitchRow
|
2025-09-27 20:22:48 +02:00
|
|
|
label="/konosend"
|
|
|
|
|
subLabel="Send random image from KonoChan to channel"
|
2025-09-27 20:15:20 +02:00
|
|
|
icon={getAssetIDByName("ic_image")}
|
2025-09-27 20:30:21 +02:00
|
|
|
value={storage.enabledCommands.konosend}
|
|
|
|
|
onValueChange={(v) => handleCommandToggle("konosend", v)}
|
2025-09-27 20:15:20 +02:00
|
|
|
/>
|
|
|
|
|
</TableRowGroup>
|
2025-09-27 20:10:37 +02:00
|
|
|
|
2025-09-27 20:15:20 +02:00
|
|
|
{/* About Section */}
|
|
|
|
|
<TableRowGroup title="About">
|
2025-09-27 20:44:51 +02:00
|
|
|
<TableRow
|
2025-09-27 20:15:20 +02:00
|
|
|
label="All-In-One Commands"
|
|
|
|
|
subLabel="A collection of useful commands"
|
|
|
|
|
icon={getAssetIDByName("ic_badge_staff")}
|
|
|
|
|
/>
|
|
|
|
|
</TableRowGroup>
|
|
|
|
|
</Stack>
|
|
|
|
|
</ScrollView>
|
|
|
|
|
</View>
|
2025-09-27 19:40:15 +02:00
|
|
|
);
|
2025-09-27 20:10:37 +02:00
|
|
|
}
|