From ae4c9863f7eff60b03f173ff78235404f29681a1 Mon Sep 17 00:00:00 2001 From: fumiichan <35658068+fumiichan@users.noreply.github.com> Date: Sun, 2 Feb 2025 22:28:45 +0900 Subject: [PATCH] Refine logic for detecting hide-able messages from authors in filter list --- src/plugins/hideAttachments/index.tsx | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/plugins/hideAttachments/index.tsx b/src/plugins/hideAttachments/index.tsx index 31b903401..c1becff48 100644 --- a/src/plugins/hideAttachments/index.tsx +++ b/src/plugins/hideAttachments/index.tsx @@ -64,15 +64,22 @@ const toggleHide = async (channelId: string, messageId: string): Promise = * @returns {boolean} */ const shouldHideByUserIdFilter = (payload: IMessage, userFilters: Set): boolean => { - if (!payload.attachments.length && !payload.embeds.length) { - return false; + if (userFilters.has(payload.author.id)) { + // Check if it's a forwarded messages with embeds/attachments + if (Array.isArray(payload.message_snapshots)) { + const hasMedia = payload.message_snapshots.some(snapshot => { + return snapshot.message.attachments.length > 0 || snapshot.message.embeds.length > 0; + }); + if (hasMedia) { + return true; + } + } + + // Otherwise, just check if the message contain embeds/attachments + return payload.attachments.length > 0 || payload.embeds.length > 0; } - if (!Array.isArray(payload.message_snapshots)) { - return false; - } - - return userFilters.has(payload.author.id); + return false; }; /**