1
0
Fork 1
mirror of https://github.com/Vendicated/Vencord.git synced 2025-01-09 17:36:23 +00:00

Allow suppression of embeds when message is forwarded

This commit is contained in:
jamesbt365 2024-10-04 01:12:30 +01:00
parent 832e874c35
commit 8cac0dc60b
No known key found for this signature in database
GPG key ID: B375A092448F9102

View file

@ -24,9 +24,21 @@ import { Constants, Menu, PermissionsBits, PermissionStore, RestAPI, UserStore }
const EMBED_SUPPRESSED = 1 << 2;
const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { channel, message: { author, embeds, flags, id: messageId } }) => {
interface Snapshot {
message: {
embeds: any[];
};
}
const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { channel, message: { author, messageSnapshots, embeds, flags, id: messageId } }) => {
const isEmbedSuppressed = (flags & EMBED_SUPPRESSED) !== 0;
if (!isEmbedSuppressed && !embeds.length) return;
const hasEmbedsInSnapshots = messageSnapshots.some(
(snapshot: Snapshot) => snapshot?.message.embeds.length
);
if (!isEmbedSuppressed && !embeds.length && !hasEmbedsInSnapshots) {
return;
}
const hasEmbedPerms = channel.isPrivate() || !!(PermissionStore.getChannelPermissions({ id: channel.id }) & PermissionsBits.EMBED_LINKS);
if (author.id === UserStore.getCurrentUser().id && !hasEmbedPerms) return;