diff --git a/src/plugins/hideMessages/index.tsx b/src/plugins/hideMessages/index.tsx new file mode 100644 index 0000000000..28bc0dbcdb --- /dev/null +++ b/src/plugins/hideMessages/index.tsx @@ -0,0 +1,70 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2026 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu"; +import { definePluginSettings } from "@api/Settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { IconComponent, OptionType } from "@utils/types"; +import { Message } from "@vencord/discord-types"; +import { findExportedComponentLazy } from "@webpack"; +import { ChannelStore, FluxDispatcher, Menu } from "@webpack/common"; + +const EyeIconLazy = findExportedComponentLazy("EyeIcon"); +const EyeIcon: IconComponent = props => ; + +const hideMessage = (messageId: string, channelId: string) => { + FluxDispatcher.dispatch({ + type: "MESSAGE_DELETE", + id: messageId, + channelId, + mlDeleted: true, + }); +}; + +const messageCtxPatch: NavContextMenuPatchCallback = (children, { message }: { message: Message; }) => { + const group = findGroupChildrenByChildId("copy-text", children); + if (!group) return; + + group.splice(group.findIndex(c => c?.props?.id === "copy-text") + 1, 0, ( + hideMessage(message.id, message.channel_id)} + /> + )); +}; + +const settings = definePluginSettings({ + hidePopoverButton: { + type: OptionType.BOOLEAN, + description: "Hide the hide button in the message popover.", + default: false + } +}); + +export default definePlugin({ + name: "HideMessages", + description: "A plugin to temporarily hide messages until you restart.", + authors: [Devs.yash], + contextMenus: { + "message": messageCtxPatch + }, + settings, + messagePopoverButton: { + icon: EyeIcon, + render(message: Message) { + if (settings.store.hidePopoverButton) return null; + return { + label: "Hide", + icon: EyeIcon, + message, + channel: ChannelStore.getChannel(message.channel_id), + onClick: () => hideMessage(message.id, message.channel_id) + }; + } + } +}); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index c3b784716d..cc0ae2cc6e 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -629,6 +629,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "prism", id: 390884143749136386n, }, + yash: { + name: "yash", + id: 889150838658977874n, + }, } satisfies Record); // iife so #__PURE__ works correctly