mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-10 09:56:24 +00:00
Allow suppression of embeds when message is forwarded
This commit is contained in:
parent
832e874c35
commit
8cac0dc60b
1 changed files with 14 additions and 2 deletions
|
@ -24,9 +24,21 @@ import { Constants, Menu, PermissionsBits, PermissionStore, RestAPI, UserStore }
|
||||||
|
|
||||||
const EMBED_SUPPRESSED = 1 << 2;
|
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;
|
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);
|
const hasEmbedPerms = channel.isPrivate() || !!(PermissionStore.getChannelPermissions({ id: channel.id }) & PermissionsBits.EMBED_LINKS);
|
||||||
if (author.id === UserStore.getCurrentUser().id && !hasEmbedPerms) return;
|
if (author.id === UserStore.getCurrentUser().id && !hasEmbedPerms) return;
|
||||||
|
|
Loading…
Reference in a new issue