Remove icons from settings and update restart behavior
- Removes all icon props from TableRow and TableSwitchRow components - Replaces direct Discord reload with a confirmation alert when changes require restart - Refactors sendMessage to support ephemeral responses for slash commands
This commit is contained in:
parent
9261c983aa
commit
295665363a
3 changed files with 53 additions and 75 deletions
|
|
@ -1,11 +1,10 @@
|
|||
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 { BundleUpdaterManager } from "@vendetta/metro/common";
|
||||
import { alerts } from "@vendetta/ui";
|
||||
|
||||
const { ScrollView } = findByProps("ScrollView");
|
||||
const { TableRowGroup, TableSwitchRow, Stack, TableRow } = findByProps(
|
||||
|
|
@ -56,7 +55,13 @@ export default function Settings() {
|
|||
return () => {
|
||||
if (storage.pendingRestart) {
|
||||
storage.pendingRestart = false;
|
||||
BundleUpdaterManager.reload();
|
||||
alerts.showConfirmationAlert({
|
||||
title: "Restart Required",
|
||||
content:
|
||||
"You have made changes to commands. Please restart Discord to apply these changes.",
|
||||
confirmText: "Okay",
|
||||
cancelText: null,
|
||||
});
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
|
@ -79,7 +84,6 @@ export default function Settings() {
|
|||
<TableSwitchRow
|
||||
label="Send as Reply"
|
||||
subLabel="Send facts as a reply to the command message"
|
||||
icon={getAssetIDByName("ic_reply_24px")}
|
||||
value={storage.factSettings?.sendAsReply ?? true}
|
||||
onValueChange={(v: boolean) => {
|
||||
storage.factSettings.sendAsReply = v;
|
||||
|
|
@ -89,7 +93,6 @@ export default function Settings() {
|
|||
<TableSwitchRow
|
||||
label="Include Source Citation"
|
||||
subLabel="Include the source of facts when available"
|
||||
icon={getAssetIDByName("ic_info")}
|
||||
value={storage.factSettings?.includeCitation ?? false}
|
||||
onValueChange={(v: boolean) => {
|
||||
storage.factSettings.includeCitation = v;
|
||||
|
|
@ -99,21 +102,18 @@ export default function Settings() {
|
|||
<TableSwitchRow
|
||||
label="/catfact"
|
||||
subLabel="Get random cat facts"
|
||||
icon={getAssetIDByName("ic_info")}
|
||||
value={storage.enabledCommands?.catfact ?? true}
|
||||
onValueChange={(v) => handleCommandToggle("catfact", v)}
|
||||
/>
|
||||
<TableSwitchRow
|
||||
label="/dogfact"
|
||||
subLabel="Get random dog facts"
|
||||
icon={getAssetIDByName("ic_info")}
|
||||
value={storage.enabledCommands?.dogfact ?? true}
|
||||
onValueChange={(v) => handleCommandToggle("dogfact", v)}
|
||||
/>
|
||||
<TableSwitchRow
|
||||
label="/useless"
|
||||
subLabel="Get random useless facts"
|
||||
icon={getAssetIDByName("ic_info")}
|
||||
value={storage.enabledCommands?.useless ?? true}
|
||||
onValueChange={(v) => handleCommandToggle("useless", v)}
|
||||
/>
|
||||
|
|
@ -124,7 +124,6 @@ export default function Settings() {
|
|||
<TableSwitchRow
|
||||
label="Always Send Detailed Plugin List"
|
||||
subLabel="Always use detailed mode when listing plugins"
|
||||
icon={getAssetIDByName("ic_message_copy")}
|
||||
value={storage.listSettings?.pluginListAlwaysDetailed ?? false}
|
||||
onValueChange={(v: boolean) => {
|
||||
storage.listSettings.pluginListAlwaysDetailed = v;
|
||||
|
|
@ -134,7 +133,6 @@ export default function Settings() {
|
|||
<TableSwitchRow
|
||||
label="Always Send Detailed Theme List"
|
||||
subLabel="Always use detailed mode when listing themes"
|
||||
icon={getAssetIDByName("ic_theme")}
|
||||
value={storage.listSettings?.themeListAlwaysDetailed ?? false}
|
||||
onValueChange={(v: boolean) => {
|
||||
storage.listSettings.themeListAlwaysDetailed = v;
|
||||
|
|
@ -144,14 +142,12 @@ export default function Settings() {
|
|||
<TableSwitchRow
|
||||
label="/plugin-list"
|
||||
subLabel="List all installed plugins"
|
||||
icon={getAssetIDByName("ic_plugins")}
|
||||
value={storage.enabledCommands?.pluginList ?? true}
|
||||
onValueChange={(v) => handleCommandToggle("pluginList", v)}
|
||||
/>
|
||||
<TableSwitchRow
|
||||
label="/theme-list"
|
||||
subLabel="List all installed themes"
|
||||
icon={getAssetIDByName("ic_theme")}
|
||||
value={storage.enabledCommands?.themeList ?? true}
|
||||
onValueChange={(v) => handleCommandToggle("themeList", v)}
|
||||
/>
|
||||
|
|
@ -162,7 +158,6 @@ export default function Settings() {
|
|||
<TableSwitchRow
|
||||
label="/petpet"
|
||||
subLabel="Create pet-pet GIF of a user"
|
||||
icon={getAssetIDByName("ic_image")}
|
||||
value={storage.enabledCommands?.petpet ?? true}
|
||||
onValueChange={(v) => handleCommandToggle("petpet", v)}
|
||||
/>
|
||||
|
|
@ -173,14 +168,12 @@ export default function Settings() {
|
|||
<TableSwitchRow
|
||||
label="/konoself"
|
||||
subLabel="Get random image from KonoChan (private)"
|
||||
icon={getAssetIDByName("ic_image")}
|
||||
value={storage.enabledCommands?.konoself ?? true}
|
||||
onValueChange={(v) => handleCommandToggle("konoself", v)}
|
||||
/>
|
||||
<TableSwitchRow
|
||||
label="/konosend"
|
||||
subLabel="Send random image from KonoChan to channel"
|
||||
icon={getAssetIDByName("ic_image")}
|
||||
value={storage.enabledCommands?.konosend ?? true}
|
||||
onValueChange={(v) => handleCommandToggle("konosend", v)}
|
||||
/>
|
||||
|
|
@ -188,35 +181,12 @@ export default function Settings() {
|
|||
|
||||
{/* Credits */}
|
||||
<TableRowGroup title="Credits">
|
||||
<TableRow
|
||||
label="Facts Commands"
|
||||
subLabel="by jdev082"
|
||||
icon={getAssetIDByName("ic_info")}
|
||||
/>
|
||||
<TableRow
|
||||
label="List Commands"
|
||||
subLabel="by Kitomanari"
|
||||
icon={getAssetIDByName("ic_list")}
|
||||
/>
|
||||
<TableRow
|
||||
label="PetPet Command"
|
||||
subLabel="by wolfieeee"
|
||||
icon={getAssetIDByName("ic_image")}
|
||||
/>
|
||||
<TableRow label="Facts Commands" subLabel="by jdev082" />
|
||||
<TableRow label="List Commands" subLabel="by Kitomanari" />
|
||||
<TableRow label="PetPet Command" subLabel="by wolfieeee" />
|
||||
<TableRow
|
||||
label="KonoChan Commands"
|
||||
subLabel="by btmc727 & Rico040"
|
||||
icon={getAssetIDByName("ic_image")}
|
||||
/>
|
||||
</TableRowGroup>
|
||||
|
||||
{/* Actions */}
|
||||
<TableRowGroup title="Actions">
|
||||
<TableRow
|
||||
label="Reload Discord"
|
||||
subLabel="Apply command changes"
|
||||
icon={getAssetIDByName("ic_message_retry")}
|
||||
onPress={() => BundleUpdaterManager.reload()}
|
||||
/>
|
||||
</TableRowGroup>
|
||||
|
||||
|
|
@ -225,7 +195,6 @@ export default function Settings() {
|
|||
<TableRow
|
||||
label="All-In-One Commands"
|
||||
subLabel="A collection of useful commands"
|
||||
icon={getAssetIDByName("ic_badge_staff")}
|
||||
/>
|
||||
</TableRowGroup>
|
||||
</Stack>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { findByProps } from "@vendetta/metro";
|
||||
import { alerts } from "@vendetta/ui";
|
||||
import { sendMessage } from "../utils/messages";
|
||||
import { alerts } from "@vendetta/ui";
|
||||
|
||||
/**
|
||||
* Fetches a random image from KonoChan.
|
||||
|
|
@ -28,16 +28,6 @@ const fetchImage = async (isNSFW: boolean): Promise<string | null> => {
|
|||
}
|
||||
};
|
||||
|
||||
// Common options for both commands
|
||||
const nsfwOption = {
|
||||
name: "nsfw",
|
||||
description: "Include NSFW content?",
|
||||
type: 5,
|
||||
required: false,
|
||||
displayName: "nsfw",
|
||||
displayDescription: "Include NSFW content?",
|
||||
};
|
||||
|
||||
const showNSFWWarning = () => {
|
||||
return alerts.showConfirmationAlert({
|
||||
title: "NSFW Content Warning",
|
||||
|
|
@ -49,6 +39,16 @@ const showNSFWWarning = () => {
|
|||
});
|
||||
};
|
||||
|
||||
// Common options for both commands
|
||||
const nsfwOption = {
|
||||
name: "nsfw",
|
||||
description: "Include NSFW content?",
|
||||
type: 5,
|
||||
required: false,
|
||||
displayName: "nsfw",
|
||||
displayDescription: "Include NSFW content?",
|
||||
};
|
||||
|
||||
export const konoSelfCommand = {
|
||||
name: "konoself",
|
||||
displayName: "konoself",
|
||||
|
|
@ -68,19 +68,22 @@ export const konoSelfCommand = {
|
|||
const imageUrl = await fetchImage(isNSFW);
|
||||
|
||||
if (!imageUrl) {
|
||||
return {
|
||||
type: 4,
|
||||
data: { content: "No image found. Try again later.", flags: 64 },
|
||||
};
|
||||
return sendMessage(
|
||||
ctx.channel.id,
|
||||
"No image found. Try again later.",
|
||||
undefined,
|
||||
undefined,
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 4,
|
||||
data: {
|
||||
content: `Here's your random image: ${imageUrl}`,
|
||||
flags: 64, // This makes the message ephemeral (only visible to you)
|
||||
},
|
||||
};
|
||||
return sendMessage(
|
||||
ctx.channel.id,
|
||||
`Here's your random image: ${imageUrl}`,
|
||||
undefined,
|
||||
undefined,
|
||||
true,
|
||||
);
|
||||
},
|
||||
applicationId: "-1",
|
||||
inputType: 1,
|
||||
|
|
|
|||
|
|
@ -1,17 +1,29 @@
|
|||
import { findByProps } from "@vendetta/metro";
|
||||
import { showToast } from "@vendetta/ui/toasts";
|
||||
|
||||
const MessageActions = findByProps("sendMessage");
|
||||
|
||||
export const sendMessage = async (
|
||||
export const sendMessage = (
|
||||
channelId: string,
|
||||
content: string,
|
||||
replyToId?: string,
|
||||
storage?: any,
|
||||
ephemeral?: boolean,
|
||||
) => {
|
||||
// Only return acknowledgment for slash command
|
||||
// If no content, just acknowledge the command
|
||||
if (!content) return { type: 4 };
|
||||
|
||||
// For ephemeral messages, return special format
|
||||
if (ephemeral) {
|
||||
return {
|
||||
type: 4,
|
||||
data: {
|
||||
content,
|
||||
flags: 64,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// For normal messages, send through MessageActions
|
||||
const message = {
|
||||
content,
|
||||
...(replyToId && storage?.factSettings?.sendAsReply
|
||||
|
|
@ -19,15 +31,9 @@ export const sendMessage = async (
|
|||
: {}),
|
||||
};
|
||||
|
||||
// Use a promise to ensure message is sent before returning
|
||||
await MessageActions.sendMessage(channelId, message, void 0, {
|
||||
MessageActions.sendMessage(channelId, message, void 0, {
|
||||
nonce: (Date.now() * 4194304).toString(),
|
||||
});
|
||||
|
||||
// Return acknowledgment without content to prevent double sending
|
||||
return { type: 4 };
|
||||
};
|
||||
|
||||
export const showAlert = (message: string) => {
|
||||
showToast(message, findByProps("Alerts").Alerts.ERROR);
|
||||
return { type: 4 }; // Acknowledge the command
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue