diff --git a/src/plugins/viewRaw/index.tsx b/src/plugins/viewRaw/index.tsx
index bfcb9ba40..269eb36ee 100644
--- a/src/plugins/viewRaw/index.tsx
+++ b/src/plugins/viewRaw/index.tsx
@@ -16,7 +16,7 @@
* along with this program. If not, see .
*/
-import { NavContextMenuPatchCallback } from "@api/ContextMenu";
+import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
import { definePluginSettings } from "@api/Settings";
import { CodeBlock } from "@components/CodeBlock";
import { Divider } from "@components/Divider";
@@ -124,31 +124,36 @@ const settings = definePluginSettings({
{ label: "Left Click to view the raw content.", value: "Left", default: true },
{ label: "Right click to view the raw content.", value: "Right" }
]
+ },
+ messageContextMenu: {
+ description: "Show in message context menu",
+ type: OptionType.BOOLEAN,
+ default: false
}
});
-function MakeContextCallback(name: "Guild" | "Role" | "User" | "Channel"): NavContextMenuPatchCallback {
+function MakeContextCallback(name: "Guild" | "Role" | "User" | "Channel" | "Message"): NavContextMenuPatchCallback {
return (children, props) => {
const value = props[name.toLowerCase()];
if (!value) return;
if (props.label === getIntlMessage("CHANNEL_ACTIONS_MENU_LABEL")) return; // random shit like notification settings
+ const isMessage = name === "Message";
+ if (isMessage && !settings.store.messageContextMenu) return;
- const lastChild = children.at(-1);
- if (lastChild?.key === "developer-actions") {
- const p = lastChild.props;
- if (!Array.isArray(p.children))
- p.children = [p.children];
-
- children = p.children;
- }
// typescript parser goes crazy if this is inline
const id = `vc-view-${name.toLowerCase()}-raw`;
- children.splice(-1, 0,
+ const action = isMessage
+ ? () => openViewRawModalMessage(value)
+ : () => openViewRawModal(JSON.stringify(value, null, 4), name);
+
+ const devContainer = findGroupChildrenByChildId(`devmode-copy-id-${value.id}`, children);
+
+ (devContainer ?? children).splice(-1, 0,
openViewRawModal(JSON.stringify(value, null, 4), name)}
+ action={action}
icon={CopyIcon}
/>
);
@@ -186,7 +191,8 @@ export default definePlugin({
"thread-context": MakeContextCallback("Channel"),
"gdm-context": MakeContextCallback("Channel"),
"user-context": MakeContextCallback("User"),
- "dev-context": devContextCallback
+ "dev-context": devContextCallback,
+ "message": MakeContextCallback("Message"),
},
messagePopoverButton: {