diff --git a/packages/discord-types/src/common/messages/Message.d.ts b/packages/discord-types/src/common/messages/Message.d.ts index 38010cafb..41de88162 100644 --- a/packages/discord-types/src/common/messages/Message.d.ts +++ b/packages/discord-types/src/common/messages/Message.d.ts @@ -83,6 +83,9 @@ export class Message extends DiscordRecord { channel_id: string; message_id: string; } | undefined; + messageSnapshots: { + message: Message; + }[]; nick: unknown; // probably a string nonce: string | undefined; pinned: boolean; diff --git a/src/equicordplugins/equicordToolbox/index.tsx b/src/equicordplugins/equicordToolbox/index.tsx index a98b73818..b20c123e7 100644 --- a/src/equicordplugins/equicordToolbox/index.tsx +++ b/src/equicordplugins/equicordToolbox/index.tsx @@ -163,7 +163,7 @@ export default definePlugin({ patches: [ { - find: "=!0,toolbar:", + find: ".controlButtonWrapper,", replacement: { match: /(?<=function (\i).{0,100}\()\i.Fragment,(?=.+?toolbar:\1\(\))/, replace: "$self.ToolboxFragmentWrapper," diff --git a/src/plugins/_api/notices.ts b/src/plugins/_api/notices.ts index 774cd36f3..f0933ff0f 100644 --- a/src/plugins/_api/notices.ts +++ b/src/plugins/_api/notices.ts @@ -33,8 +33,8 @@ export default definePlugin({ replace: "if(Vencord.Api.Notices.currentNotice)return false;$&" }, { - match: /(?<=function \i\(\i\){)return null!=(\i)/, - replace: "if($1?.id==\"EquicordNotice\")return($1=null,Vencord.Api.Notices.nextNotice(),true);$&" + match: /(?<=function (\i)\(\i\){)return null!=(\i)(?=.+?NOTICE_DISMISS:\1)/, + replace: (m, _, notice) => `if(${notice}?.id=="EquicordNotice")return(${notice}=null,Vencord.Api.Notices.nextNotice(),true);${m}` } ] } diff --git a/src/plugins/hideAttachments/index.tsx b/src/plugins/hideAttachments/index.tsx index 4927c247f..6186899fb 100644 --- a/src/plugins/hideAttachments/index.tsx +++ b/src/plugins/hideAttachments/index.tsx @@ -25,7 +25,7 @@ import { ImageInvisible, ImageVisible } from "@components/Icons"; import { Devs } from "@utils/constants"; import { classes } from "@utils/misc"; import definePlugin from "@utils/types"; -import { MessageSnapshot } from "@vencord/discord-types"; +import { Message } from "@vencord/discord-types"; import { ChannelStore } from "@webpack/common"; const KEY = "HideAttachments_HiddenIds"; @@ -41,6 +41,8 @@ const saveHiddenMessages = (ids: Set) => set(KEY, ids); migratePluginSettings("HideMedia", "HideAttachments"); +const hasMedia = (msg: Message) => msg.attachments.length > 0 || msg.embeds.length > 0 || msg.stickerItems.length > 0; + export default definePlugin({ name: "HideMedia", description: "Hide attachments and embeds for individual messages via hover button", @@ -56,12 +58,7 @@ export default definePlugin({ }], renderMessagePopoverButton(msg) { - // @ts-expect-error - discord-types lags behind discord. - const hasAttachmentsInShapshots = msg.messageSnapshots.some( - (snapshot: MessageSnapshot) => snapshot?.message.attachments.length - ); - - if (!msg.attachments.length && !msg.embeds.length && !msg.stickerItems.length && !hasAttachmentsInShapshots) return null; + if (!hasMedia(msg) && !msg.messageSnapshots.some(s => hasMedia(s.message))) return null; const isHidden = hiddenMessages instanceof Set ? hiddenMessages.has(msg.id) : false; diff --git a/src/plugins/reviewDB/index.tsx b/src/plugins/reviewDB/index.tsx index 717f8ec8a..548a476d1 100644 --- a/src/plugins/reviewDB/index.tsx +++ b/src/plugins/reviewDB/index.tsx @@ -84,14 +84,6 @@ export default definePlugin({ replace: "$&$self.BiteSizeReviewsButton({user:arguments[0].user})," } }, - { - find: ".MODAL,user:", - replacement: { - match: /children:\[(?=[^[]+?shouldShowTooltip:)/, - replace: "$&$self.BiteSizeReviewsButton({user:arguments[0].user})," - } - }, - // places like the user profile on the right in dms { find: ".SIDEBAR,shouldShowTooltip:", replacement: { diff --git a/src/plugins/showAllMessageButtons/index.ts b/src/plugins/showAllMessageButtons/index.ts index a2d8ced50..4d209d2b0 100644 --- a/src/plugins/showAllMessageButtons/index.ts +++ b/src/plugins/showAllMessageButtons/index.ts @@ -36,8 +36,8 @@ export default definePlugin({ find: "#{intl::MESSAGE_UTILITIES_A11Y_LABEL}", replacement: [ { - match: /(\i)=\i&&(!\i.+?)/, - replace: "$1=$2" + match: /(?<=(\i)=)\i(?=&&.+?isExpanded:\1)/, + replace: "true" }, { predicate: () => settings.store.noShiftDelete, diff --git a/src/plugins/superReactionTweaks/index.ts b/src/plugins/superReactionTweaks/index.ts index ae01c050a..8b0e55f97 100644 --- a/src/plugins/superReactionTweaks/index.ts +++ b/src/plugins/superReactionTweaks/index.ts @@ -42,8 +42,8 @@ export default definePlugin({ { find: ",BURST_REACTION_EFFECT_PLAY", replacement: { - match: /(\i=>{.{50,100})(\i\(\i,\i\))>=\i/, - replace: "$1!$self.shouldPlayBurstReaction($2)" + match: /(?<=(\i)=\i=>{.+?)(\i\(\i,\i\))>=\i(?=\).+BURST_REACTION_EFFECT_PLAY:\1)/, + replace: "!$self.shouldPlayBurstReaction($2)" } }, { diff --git a/src/plugins/unsuppressEmbeds/index.tsx b/src/plugins/unsuppressEmbeds/index.tsx index e5f8557f9..9eecd86d7 100644 --- a/src/plugins/unsuppressEmbeds/index.tsx +++ b/src/plugins/unsuppressEmbeds/index.tsx @@ -20,17 +20,18 @@ import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/Co import { ImageInvisible, ImageVisible } from "@components/Icons"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; -import { MessageSnapshot } from "@vencord/discord-types"; +import { Channel, Message } from "@vencord/discord-types"; import { Constants, Menu, PermissionsBits, PermissionStore, RestAPI, UserStore } from "@webpack/common"; const EMBED_SUPPRESSED = 1 << 2; -const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { channel, message: { author, messageSnapshots, embeds, flags, id: messageId } }) => { +const messageContextMenuPatch: NavContextMenuPatchCallback = ( + children, + { channel, message: { author, messageSnapshots, embeds, flags, id: messageId } }: { channel: Channel; message: Message; } +) => { const isEmbedSuppressed = (flags & EMBED_SUPPRESSED) !== 0; - const hasEmbedsInSnapshots = messageSnapshots.some( - (snapshot: MessageSnapshot) => snapshot?.message.embeds.length - ); + const hasEmbedsInSnapshots = messageSnapshots.some(s => s.message.embeds.length); if (!isEmbedSuppressed && !embeds.length && !hasEmbedsInSnapshots) return;