From 295665363ad333dea9380a314ca40ead34cb181f Mon Sep 17 00:00:00 2001 From: kmmiio99o <164557248+kmmiio99o@users.noreply.github.com> Date: Sat, 27 Sep 2025 21:37:28 +0200 Subject: [PATCH] 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 --- plugins/all-in-one/settings.tsx | 53 +++++---------------- plugins/all-in-one/src/commands/konochan.ts | 47 +++++++++--------- plugins/all-in-one/src/utils/messages.ts | 28 ++++++----- 3 files changed, 53 insertions(+), 75 deletions(-) diff --git a/plugins/all-in-one/settings.tsx b/plugins/all-in-one/settings.tsx index f8c3aff..6dc8c15 100644 --- a/plugins/all-in-one/settings.tsx +++ b/plugins/all-in-one/settings.tsx @@ -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() { { storage.factSettings.sendAsReply = v; @@ -89,7 +93,6 @@ export default function Settings() { { storage.factSettings.includeCitation = v; @@ -99,21 +102,18 @@ export default function Settings() { handleCommandToggle("catfact", v)} /> handleCommandToggle("dogfact", v)} /> handleCommandToggle("useless", v)} /> @@ -124,7 +124,6 @@ export default function Settings() { { storage.listSettings.pluginListAlwaysDetailed = v; @@ -134,7 +133,6 @@ export default function Settings() { { storage.listSettings.themeListAlwaysDetailed = v; @@ -144,14 +142,12 @@ export default function Settings() { handleCommandToggle("pluginList", v)} /> handleCommandToggle("themeList", v)} /> @@ -162,7 +158,6 @@ export default function Settings() { handleCommandToggle("petpet", v)} /> @@ -173,14 +168,12 @@ export default function Settings() { handleCommandToggle("konoself", v)} /> handleCommandToggle("konosend", v)} /> @@ -188,35 +181,12 @@ export default function Settings() { {/* Credits */} - - - + + + - - - {/* Actions */} - - BundleUpdaterManager.reload()} /> @@ -225,7 +195,6 @@ export default function Settings() { diff --git a/plugins/all-in-one/src/commands/konochan.ts b/plugins/all-in-one/src/commands/konochan.ts index 35a5fcb..eff21e0 100644 --- a/plugins/all-in-one/src/commands/konochan.ts +++ b/plugins/all-in-one/src/commands/konochan.ts @@ -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 => { } }; -// 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, diff --git a/plugins/all-in-one/src/utils/messages.ts b/plugins/all-in-one/src/utils/messages.ts index b68fe94..6da2ef9 100644 --- a/plugins/all-in-one/src/utils/messages.ts +++ b/plugins/all-in-one/src/utils/messages.ts @@ -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 };