mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-24 07:25:10 +00:00
Refine logic for detecting hide-able messages from authors in filter list
This commit is contained in:
parent
c5b4b7e225
commit
ae4c9863f7
1 changed files with 14 additions and 7 deletions
|
@ -64,15 +64,22 @@ const toggleHide = async (channelId: string, messageId: string): Promise<void> =
|
|||
* @returns {boolean}
|
||||
*/
|
||||
const shouldHideByUserIdFilter = (payload: IMessage, userFilters: Set<string>): 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;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Array.isArray(payload.message_snapshots)) {
|
||||
return false;
|
||||
// Otherwise, just check if the message contain embeds/attachments
|
||||
return payload.attachments.length > 0 || payload.embeds.length > 0;
|
||||
}
|
||||
|
||||
return userFilters.has(payload.author.id);
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue