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 { plugin } from "@vendetta";
|
||||||
import { storage } from "@vendetta/plugin";
|
import { storage } from "@vendetta/plugin";
|
||||||
import { useProxy } from "@vendetta/storage";
|
import { useProxy } from "@vendetta/storage";
|
||||||
import { getAssetIDByName } from "@vendetta/ui/assets";
|
|
||||||
import { React } from "@vendetta/metro/common";
|
import { React } from "@vendetta/metro/common";
|
||||||
import { findByProps } from "@vendetta/metro";
|
import { findByProps } from "@vendetta/metro";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
import { BundleUpdaterManager } from "@vendetta/metro/common";
|
import { alerts } from "@vendetta/ui";
|
||||||
|
|
||||||
const { ScrollView } = findByProps("ScrollView");
|
const { ScrollView } = findByProps("ScrollView");
|
||||||
const { TableRowGroup, TableSwitchRow, Stack, TableRow } = findByProps(
|
const { TableRowGroup, TableSwitchRow, Stack, TableRow } = findByProps(
|
||||||
|
|
@ -56,7 +55,13 @@ export default function Settings() {
|
||||||
return () => {
|
return () => {
|
||||||
if (storage.pendingRestart) {
|
if (storage.pendingRestart) {
|
||||||
storage.pendingRestart = false;
|
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
|
<TableSwitchRow
|
||||||
label="Send as Reply"
|
label="Send as Reply"
|
||||||
subLabel="Send facts as a reply to the command message"
|
subLabel="Send facts as a reply to the command message"
|
||||||
icon={getAssetIDByName("ic_reply_24px")}
|
|
||||||
value={storage.factSettings?.sendAsReply ?? true}
|
value={storage.factSettings?.sendAsReply ?? true}
|
||||||
onValueChange={(v: boolean) => {
|
onValueChange={(v: boolean) => {
|
||||||
storage.factSettings.sendAsReply = v;
|
storage.factSettings.sendAsReply = v;
|
||||||
|
|
@ -89,7 +93,6 @@ export default function Settings() {
|
||||||
<TableSwitchRow
|
<TableSwitchRow
|
||||||
label="Include Source Citation"
|
label="Include Source Citation"
|
||||||
subLabel="Include the source of facts when available"
|
subLabel="Include the source of facts when available"
|
||||||
icon={getAssetIDByName("ic_info")}
|
|
||||||
value={storage.factSettings?.includeCitation ?? false}
|
value={storage.factSettings?.includeCitation ?? false}
|
||||||
onValueChange={(v: boolean) => {
|
onValueChange={(v: boolean) => {
|
||||||
storage.factSettings.includeCitation = v;
|
storage.factSettings.includeCitation = v;
|
||||||
|
|
@ -99,21 +102,18 @@ export default function Settings() {
|
||||||
<TableSwitchRow
|
<TableSwitchRow
|
||||||
label="/catfact"
|
label="/catfact"
|
||||||
subLabel="Get random cat facts"
|
subLabel="Get random cat facts"
|
||||||
icon={getAssetIDByName("ic_info")}
|
|
||||||
value={storage.enabledCommands?.catfact ?? true}
|
value={storage.enabledCommands?.catfact ?? true}
|
||||||
onValueChange={(v) => handleCommandToggle("catfact", v)}
|
onValueChange={(v) => handleCommandToggle("catfact", v)}
|
||||||
/>
|
/>
|
||||||
<TableSwitchRow
|
<TableSwitchRow
|
||||||
label="/dogfact"
|
label="/dogfact"
|
||||||
subLabel="Get random dog facts"
|
subLabel="Get random dog facts"
|
||||||
icon={getAssetIDByName("ic_info")}
|
|
||||||
value={storage.enabledCommands?.dogfact ?? true}
|
value={storage.enabledCommands?.dogfact ?? true}
|
||||||
onValueChange={(v) => handleCommandToggle("dogfact", v)}
|
onValueChange={(v) => handleCommandToggle("dogfact", v)}
|
||||||
/>
|
/>
|
||||||
<TableSwitchRow
|
<TableSwitchRow
|
||||||
label="/useless"
|
label="/useless"
|
||||||
subLabel="Get random useless facts"
|
subLabel="Get random useless facts"
|
||||||
icon={getAssetIDByName("ic_info")}
|
|
||||||
value={storage.enabledCommands?.useless ?? true}
|
value={storage.enabledCommands?.useless ?? true}
|
||||||
onValueChange={(v) => handleCommandToggle("useless", v)}
|
onValueChange={(v) => handleCommandToggle("useless", v)}
|
||||||
/>
|
/>
|
||||||
|
|
@ -124,7 +124,6 @@ export default function Settings() {
|
||||||
<TableSwitchRow
|
<TableSwitchRow
|
||||||
label="Always Send Detailed Plugin List"
|
label="Always Send Detailed Plugin List"
|
||||||
subLabel="Always use detailed mode when listing plugins"
|
subLabel="Always use detailed mode when listing plugins"
|
||||||
icon={getAssetIDByName("ic_message_copy")}
|
|
||||||
value={storage.listSettings?.pluginListAlwaysDetailed ?? false}
|
value={storage.listSettings?.pluginListAlwaysDetailed ?? false}
|
||||||
onValueChange={(v: boolean) => {
|
onValueChange={(v: boolean) => {
|
||||||
storage.listSettings.pluginListAlwaysDetailed = v;
|
storage.listSettings.pluginListAlwaysDetailed = v;
|
||||||
|
|
@ -134,7 +133,6 @@ export default function Settings() {
|
||||||
<TableSwitchRow
|
<TableSwitchRow
|
||||||
label="Always Send Detailed Theme List"
|
label="Always Send Detailed Theme List"
|
||||||
subLabel="Always use detailed mode when listing themes"
|
subLabel="Always use detailed mode when listing themes"
|
||||||
icon={getAssetIDByName("ic_theme")}
|
|
||||||
value={storage.listSettings?.themeListAlwaysDetailed ?? false}
|
value={storage.listSettings?.themeListAlwaysDetailed ?? false}
|
||||||
onValueChange={(v: boolean) => {
|
onValueChange={(v: boolean) => {
|
||||||
storage.listSettings.themeListAlwaysDetailed = v;
|
storage.listSettings.themeListAlwaysDetailed = v;
|
||||||
|
|
@ -144,14 +142,12 @@ export default function Settings() {
|
||||||
<TableSwitchRow
|
<TableSwitchRow
|
||||||
label="/plugin-list"
|
label="/plugin-list"
|
||||||
subLabel="List all installed plugins"
|
subLabel="List all installed plugins"
|
||||||
icon={getAssetIDByName("ic_plugins")}
|
|
||||||
value={storage.enabledCommands?.pluginList ?? true}
|
value={storage.enabledCommands?.pluginList ?? true}
|
||||||
onValueChange={(v) => handleCommandToggle("pluginList", v)}
|
onValueChange={(v) => handleCommandToggle("pluginList", v)}
|
||||||
/>
|
/>
|
||||||
<TableSwitchRow
|
<TableSwitchRow
|
||||||
label="/theme-list"
|
label="/theme-list"
|
||||||
subLabel="List all installed themes"
|
subLabel="List all installed themes"
|
||||||
icon={getAssetIDByName("ic_theme")}
|
|
||||||
value={storage.enabledCommands?.themeList ?? true}
|
value={storage.enabledCommands?.themeList ?? true}
|
||||||
onValueChange={(v) => handleCommandToggle("themeList", v)}
|
onValueChange={(v) => handleCommandToggle("themeList", v)}
|
||||||
/>
|
/>
|
||||||
|
|
@ -162,7 +158,6 @@ export default function Settings() {
|
||||||
<TableSwitchRow
|
<TableSwitchRow
|
||||||
label="/petpet"
|
label="/petpet"
|
||||||
subLabel="Create pet-pet GIF of a user"
|
subLabel="Create pet-pet GIF of a user"
|
||||||
icon={getAssetIDByName("ic_image")}
|
|
||||||
value={storage.enabledCommands?.petpet ?? true}
|
value={storage.enabledCommands?.petpet ?? true}
|
||||||
onValueChange={(v) => handleCommandToggle("petpet", v)}
|
onValueChange={(v) => handleCommandToggle("petpet", v)}
|
||||||
/>
|
/>
|
||||||
|
|
@ -173,14 +168,12 @@ export default function Settings() {
|
||||||
<TableSwitchRow
|
<TableSwitchRow
|
||||||
label="/konoself"
|
label="/konoself"
|
||||||
subLabel="Get random image from KonoChan (private)"
|
subLabel="Get random image from KonoChan (private)"
|
||||||
icon={getAssetIDByName("ic_image")}
|
|
||||||
value={storage.enabledCommands?.konoself ?? true}
|
value={storage.enabledCommands?.konoself ?? true}
|
||||||
onValueChange={(v) => handleCommandToggle("konoself", v)}
|
onValueChange={(v) => handleCommandToggle("konoself", v)}
|
||||||
/>
|
/>
|
||||||
<TableSwitchRow
|
<TableSwitchRow
|
||||||
label="/konosend"
|
label="/konosend"
|
||||||
subLabel="Send random image from KonoChan to channel"
|
subLabel="Send random image from KonoChan to channel"
|
||||||
icon={getAssetIDByName("ic_image")}
|
|
||||||
value={storage.enabledCommands?.konosend ?? true}
|
value={storage.enabledCommands?.konosend ?? true}
|
||||||
onValueChange={(v) => handleCommandToggle("konosend", v)}
|
onValueChange={(v) => handleCommandToggle("konosend", v)}
|
||||||
/>
|
/>
|
||||||
|
|
@ -188,35 +181,12 @@ export default function Settings() {
|
||||||
|
|
||||||
{/* Credits */}
|
{/* Credits */}
|
||||||
<TableRowGroup title="Credits">
|
<TableRowGroup title="Credits">
|
||||||
<TableRow
|
<TableRow label="Facts Commands" subLabel="by jdev082" />
|
||||||
label="Facts Commands"
|
<TableRow label="List Commands" subLabel="by Kitomanari" />
|
||||||
subLabel="by jdev082"
|
<TableRow label="PetPet Command" subLabel="by wolfieeee" />
|
||||||
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
|
<TableRow
|
||||||
label="KonoChan Commands"
|
label="KonoChan Commands"
|
||||||
subLabel="by btmc727 & Rico040"
|
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>
|
</TableRowGroup>
|
||||||
|
|
||||||
|
|
@ -225,7 +195,6 @@ export default function Settings() {
|
||||||
<TableRow
|
<TableRow
|
||||||
label="All-In-One Commands"
|
label="All-In-One Commands"
|
||||||
subLabel="A collection of useful commands"
|
subLabel="A collection of useful commands"
|
||||||
icon={getAssetIDByName("ic_badge_staff")}
|
|
||||||
/>
|
/>
|
||||||
</TableRowGroup>
|
</TableRowGroup>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { findByProps } from "@vendetta/metro";
|
import { findByProps } from "@vendetta/metro";
|
||||||
import { alerts } from "@vendetta/ui";
|
|
||||||
import { sendMessage } from "../utils/messages";
|
import { sendMessage } from "../utils/messages";
|
||||||
|
import { alerts } from "@vendetta/ui";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches a random image from KonoChan.
|
* 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 = () => {
|
const showNSFWWarning = () => {
|
||||||
return alerts.showConfirmationAlert({
|
return alerts.showConfirmationAlert({
|
||||||
title: "NSFW Content Warning",
|
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 = {
|
export const konoSelfCommand = {
|
||||||
name: "konoself",
|
name: "konoself",
|
||||||
displayName: "konoself",
|
displayName: "konoself",
|
||||||
|
|
@ -68,19 +68,22 @@ export const konoSelfCommand = {
|
||||||
const imageUrl = await fetchImage(isNSFW);
|
const imageUrl = await fetchImage(isNSFW);
|
||||||
|
|
||||||
if (!imageUrl) {
|
if (!imageUrl) {
|
||||||
return {
|
return sendMessage(
|
||||||
type: 4,
|
ctx.channel.id,
|
||||||
data: { content: "No image found. Try again later.", flags: 64 },
|
"No image found. Try again later.",
|
||||||
};
|
undefined,
|
||||||
|
undefined,
|
||||||
|
true,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return sendMessage(
|
||||||
type: 4,
|
ctx.channel.id,
|
||||||
data: {
|
`Here's your random image: ${imageUrl}`,
|
||||||
content: `Here's your random image: ${imageUrl}`,
|
undefined,
|
||||||
flags: 64, // This makes the message ephemeral (only visible to you)
|
undefined,
|
||||||
},
|
true,
|
||||||
};
|
);
|
||||||
},
|
},
|
||||||
applicationId: "-1",
|
applicationId: "-1",
|
||||||
inputType: 1,
|
inputType: 1,
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,29 @@
|
||||||
import { findByProps } from "@vendetta/metro";
|
import { findByProps } from "@vendetta/metro";
|
||||||
import { showToast } from "@vendetta/ui/toasts";
|
|
||||||
|
|
||||||
const MessageActions = findByProps("sendMessage");
|
const MessageActions = findByProps("sendMessage");
|
||||||
|
|
||||||
export const sendMessage = async (
|
export const sendMessage = (
|
||||||
channelId: string,
|
channelId: string,
|
||||||
content: string,
|
content: string,
|
||||||
replyToId?: string,
|
replyToId?: string,
|
||||||
storage?: any,
|
storage?: any,
|
||||||
|
ephemeral?: boolean,
|
||||||
) => {
|
) => {
|
||||||
// Only return acknowledgment for slash command
|
// If no content, just acknowledge the command
|
||||||
if (!content) return { type: 4 };
|
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 = {
|
const message = {
|
||||||
content,
|
content,
|
||||||
...(replyToId && storage?.factSettings?.sendAsReply
|
...(replyToId && storage?.factSettings?.sendAsReply
|
||||||
|
|
@ -19,15 +31,9 @@ export const sendMessage = async (
|
||||||
: {}),
|
: {}),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Use a promise to ensure message is sent before returning
|
MessageActions.sendMessage(channelId, message, void 0, {
|
||||||
await MessageActions.sendMessage(channelId, message, void 0, {
|
|
||||||
nonce: (Date.now() * 4194304).toString(),
|
nonce: (Date.now() * 4194304).toString(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Return acknowledgment without content to prevent double sending
|
return { type: 4 }; // Acknowledge the command
|
||||||
return { type: 4 };
|
|
||||||
};
|
|
||||||
|
|
||||||
export const showAlert = (message: string) => {
|
|
||||||
showToast(message, findByProps("Alerts").Alerts.ERROR);
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue