From e437498c8f1ab9fad03e2881a74002364f8ce415 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Fri, 2 Aug 2024 21:17:47 -0300 Subject: [PATCH 1/2] Fix broken patches --- src/api/{MessagePopover.ts => MessagePopover.tsx} | 10 +++++----- src/plugins/_api/messagePopover.ts | 5 ++--- src/plugins/forceOwnerCrown/index.ts | 2 +- src/plugins/showHiddenChannels/index.tsx | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) rename src/api/{MessagePopover.ts => MessagePopover.tsx} (87%) diff --git a/src/api/MessagePopover.ts b/src/api/MessagePopover.tsx similarity index 87% rename from src/api/MessagePopover.ts rename to src/api/MessagePopover.tsx index 3391cfb38..454716498 100644 --- a/src/api/MessagePopover.ts +++ b/src/api/MessagePopover.tsx @@ -18,14 +18,14 @@ import { Logger } from "@utils/Logger"; import { Channel, Message } from "discord-types/general"; -import type { MouseEventHandler } from "react"; +import type { ComponentType, MouseEventHandler, ReactElement } from "react"; const logger = new Logger("MessagePopover"); export interface ButtonItem { key?: string, label: string, - icon: React.ComponentType, + icon: ComponentType, message: Message, channel: Channel, onClick?: MouseEventHandler, @@ -49,16 +49,16 @@ export function removeButton(identifier: string) { export function _buildPopoverElements( msg: Message, - makeButton: (item: ButtonItem) => React.ComponentType + PopoverButton: ComponentType, ) { - const items = [] as React.ComponentType[]; + const items = [] as ReactElement[]; for (const [identifier, getItem] of buttons.entries()) { try { const item = getItem(msg); if (item) { item.key ??= identifier; - items.push(makeButton(item)); + items.push(); } } catch (err) { logger.error(`[${identifier}]`, err); diff --git a/src/plugins/_api/messagePopover.ts b/src/plugins/_api/messagePopover.ts index 42a1bb765..d29b9b2d0 100644 --- a/src/plugins/_api/messagePopover.ts +++ b/src/plugins/_api/messagePopover.ts @@ -26,9 +26,8 @@ export default definePlugin({ patches: [{ find: "Messages.MESSAGE_UTILITIES_A11Y_LABEL", replacement: { - // foo && !bar ? createElement(reactionStuffs)... createElement(blah,...makeElement(reply-other)) - match: /\i&&!\i\?\(0,\i\.jsxs?\)\(.{0,200}renderEmojiPicker:.{0,500}\?(\i)\(\{key:"reply-other"(?<=message:(\i).+?)/, - replace: (m, makeElement, msg) => `...Vencord.Api.MessagePopover._buildPopoverElements(${msg},${makeElement}),${m}` + match: /"reply-self".+?Fragment,{children:\[(?=.+?\((\i\.\i),{label:)(?<=message:(\i).+?)/, + replace: (m, PopoverButton, msg) => `${m}...Vencord.Api.MessagePopover._buildPopoverElements(${msg},${PopoverButton}),` } }], }); diff --git a/src/plugins/forceOwnerCrown/index.ts b/src/plugins/forceOwnerCrown/index.ts index 771583fe7..444bfab34 100644 --- a/src/plugins/forceOwnerCrown/index.ts +++ b/src/plugins/forceOwnerCrown/index.ts @@ -27,7 +27,7 @@ export default definePlugin({ authors: [Devs.D3SOX, Devs.Nickyux], patches: [ { - find: ".PREMIUM_GUILD_SUBSCRIPTION_TOOLTIP", + find: ".Messages.GUILD_OWNER,", replacement: { match: /,isOwner:(\i),/, replace: ",_isOwner:$1=$self.isGuildOwner(e)," diff --git a/src/plugins/showHiddenChannels/index.tsx b/src/plugins/showHiddenChannels/index.tsx index 68778915b..01b0da4b4 100644 --- a/src/plugins/showHiddenChannels/index.tsx +++ b/src/plugins/showHiddenChannels/index.tsx @@ -311,7 +311,7 @@ export default definePlugin({ replacement: [ { // Create a variable for the channel prop - match: /maxUsers:\i,users:\i.+?}=(\i).*?;/, + match: /users:\i,maxUsers:\i.+?}=(\i).*?;/, replace: (m, props) => `${m}let{shcChannel}=${props};` }, { From 8274b6759776299b8519ae2dee097d609a826b6b Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 3 Aug 2024 11:02:26 +0200 Subject: [PATCH 2/2] fix message hover buttons --- src/api/MessagePopover.tsx | 19 ++++++++++++------- src/plugins/_api/messagePopover.ts | 5 +++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/api/MessagePopover.tsx b/src/api/MessagePopover.tsx index 454716498..0a4a05402 100644 --- a/src/api/MessagePopover.tsx +++ b/src/api/MessagePopover.tsx @@ -16,9 +16,10 @@ * along with this program. If not, see . */ +import ErrorBoundary from "@components/ErrorBoundary"; import { Logger } from "@utils/Logger"; import { Channel, Message } from "discord-types/general"; -import type { ComponentType, MouseEventHandler, ReactElement } from "react"; +import type { ComponentType, MouseEventHandler } from "react"; const logger = new Logger("MessagePopover"); @@ -48,22 +49,26 @@ export function removeButton(identifier: string) { } export function _buildPopoverElements( - msg: Message, - PopoverButton: ComponentType, + Component: React.ComponentType, + props: { message: Message; } ) { - const items = [] as ReactElement[]; + const items: React.ReactNode[] = []; for (const [identifier, getItem] of buttons.entries()) { try { - const item = getItem(msg); + const item = getItem(props.message); if (item) { item.key ??= identifier; - items.push(); + items.push( + + + + ); } } catch (err) { logger.error(`[${identifier}]`, err); } } - return items; + return <>{items}; } diff --git a/src/plugins/_api/messagePopover.ts b/src/plugins/_api/messagePopover.ts index d29b9b2d0..9998a46b0 100644 --- a/src/plugins/_api/messagePopover.ts +++ b/src/plugins/_api/messagePopover.ts @@ -26,8 +26,9 @@ export default definePlugin({ patches: [{ find: "Messages.MESSAGE_UTILITIES_A11Y_LABEL", replacement: { - match: /"reply-self".+?Fragment,{children:\[(?=.+?\((\i\.\i),{label:)(?<=message:(\i).+?)/, - replace: (m, PopoverButton, msg) => `${m}...Vencord.Api.MessagePopover._buildPopoverElements(${msg},${PopoverButton}),` + // foo && !bar ? createElement(reactionStuffs)... createElement(blah,...makeElement(reply-other)) + match: /\i&&!\i\?\(0,\i\.jsxs?\)\(.{0,200}renderEmojiPicker:.{0,500}\?\(0,\i\.jsx\)\((\i\.\i).{0,200}\.\.\.(\i)\},"reply-other"/, + replace: "Vencord.Api.MessagePopover._buildPopoverElements($1,$2),$&" } }], });