Plugin
UnsuppressEmbeds
Allows you to unsuppress embeds in messages
1
/*2
* FiveCord — a Discord client mod3
* Copyright (c) 2025 FiveCord4
* SPDX-License-Identifier: GPL-3.0-or-later5
*/6
7
import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";8
import { ImageInvisible, ImageVisible } from "@components/Icons";9
import { Devs } from "@utils/constants";10
import definePlugin from "@utils/types";11
import { Channel, Message } from "@vencord/discord-types";12
import { Constants, Menu, PermissionsBits, PermissionStore, RestAPI, UserStore } from "@webpack/common";13
14
15
const EMBED_SUPPRESSED = 1 << 2;16
17
const messageContextMenuPatch: NavContextMenuPatchCallback = (18
children,19
{ channel, message: { author, messageSnapshots, embeds, flags, id: messageId } }: { channel: Channel; message: Message; }20
) => {21
const isEmbedSuppressed = (flags & EMBED_SUPPRESSED) !== 0;22
const hasEmbedsInSnapshots = messageSnapshots.some(s => s.message.embeds.length);23
24
if (!isEmbedSuppressed && !embeds.length && !hasEmbedsInSnapshots) return;25
26
const hasEmbedPerms = channel.isPrivate() || !!(PermissionStore.getChannelPermissions({ id: channel.id }) & PermissionsBits.EMBED_LINKS);27
if (author.id === UserStore.getCurrentUser().id && !hasEmbedPerms) return;28
29
const menuGroup = findGroupChildrenByChildId("delete", children);30
const deleteIndex = menuGroup?.findIndex(i => i?.props?.id === "delete");31
if (!deleteIndex || !menuGroup) return;32
33
menuGroup.splice(deleteIndex - 1, 0, (34
<Menu.MenuItem35
id="unsuppress-embeds"36
key="unsuppress-embeds"37
label={isEmbedSuppressed ? "Unsuppress Embeds" : "Suppress Embeds"}38
color={isEmbedSuppressed ? undefined : "danger"}39
icon={isEmbedSuppressed ? ImageVisible : ImageInvisible}40
action={() =>41
RestAPI.patch({42
url: Constants.Endpoints.MESSAGE(channel.id, messageId),43
body: { flags: isEmbedSuppressed ? flags & ~EMBED_SUPPRESSED : flags | EMBED_SUPPRESSED }44
})45
}46
/>47
));48
};49
50
export default definePlugin({51
name: "UnsuppressEmbeds",52
authors: [Devs.rad, Devs.HypedDomi],53
description: "Allows you to unsuppress embeds in messages",54
tags: ["Chat", "Utility"],55
contextMenus: {56
"message": messageContextMenuPatch57
}58
});59