import { plugin } from "@vendetta"; import { storage } from "@vendetta/plugin"; import { useProxy } from "@vendetta/storage"; import { getAssetIDByName } from "@vendetta/ui/assets"; import { React } from "@vendetta/metro/common"; import { findByProps } from "@vendetta/metro"; import { View } from "react-native"; import { alerts } from "@vendetta/ui"; const { ScrollView } = findByProps("ScrollView"); const { TableRowGroup, TableSwitchRow, Stack } = findByProps( "TableSwitchRow", "TableRowGroup", "Stack", ); // Initialize default settings if not exist if (!storage.factSettings) { storage.factSettings = { sendAsReply: true, includeCitation: false, }; } if (!storage.listSettings) { storage.listSettings = { pluginListAlwaysDetailed: false, themeListAlwaysDetailed: false, }; } if (!storage.enabledCommands) { storage.enabledCommands = { catfact: true, dogfact: true, useless: true, petpet: true, pluginList: true, themeList: true, konoself: true, konosend: true, }; } const askForRestart = (commandName: string, enabled: boolean) => { return alerts.showConfirmationAlert({ title: "Restart Required", content: `${enabled ? "Enabling" : "Disabling"} the ${commandName} command requires a Discord restart to take effect. Would you like to restart now?`, confirmText: "Restart", cancelText: "Later", confirmColor: "brand", onConfirm: () => { storage.enabledCommands[commandName] = enabled; window.enmity.plugins.reload("vendetta"); }, onCancel: () => { storage.enabledCommands[commandName] = !enabled; // Revert change if user doesn't want to restart }, }); }; export default function Settings() { useProxy(storage); const [rerender, forceRerender] = React.useReducer((x) => x + 1, 0); const handleCommandToggle = (commandName: string, value: boolean) => { askForRestart(commandName, value); forceRerender(); }; return ( {/* Facts Commands */} { storage.factSettings.sendAsReply = v; forceRerender(); }} /> { storage.factSettings.includeCitation = v; forceRerender(); }} /> handleCommandToggle("catfact", v)} /> handleCommandToggle("dogfact", v)} /> handleCommandToggle("useless", v)} /> {/* List Commands Settings */} { storage.listSettings.pluginListAlwaysDetailed = v; forceRerender(); }} /> { storage.listSettings.themeListAlwaysDetailed = v; forceRerender(); }} /> handleCommandToggle("pluginList", v)} /> handleCommandToggle("themeList", v)} /> {/* Image Commands */} handleCommandToggle("petpet", v)} /> {/* KonoChan Commands */} handleCommandToggle("konoself", v)} /> handleCommandToggle("konosend", v)} /> {/* About Section */} ); }