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