From 20ed7dc96b1ae687dff21c56481548d50a63396a Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Mon, 30 Dec 2024 00:07:26 -0500 Subject: [PATCH] new plugin FullUserInChatbox (#2766) --- src/components/ErrorBoundary.tsx | 3 +- .../accountPanelServerProfile/index.tsx | 2 +- src/plugins/fullUserInChatbox/README.md | 9 ++++ src/plugins/fullUserInChatbox/index.tsx | 47 +++++++++++++++++++ 4 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 src/plugins/fullUserInChatbox/README.md create mode 100644 src/plugins/fullUserInChatbox/index.tsx diff --git a/src/components/ErrorBoundary.tsx b/src/components/ErrorBoundary.tsx index ea2e02b51..320d40962 100644 --- a/src/components/ErrorBoundary.tsx +++ b/src/components/ErrorBoundary.tsx @@ -27,7 +27,7 @@ interface Props { /** Render nothing if an error occurs */ noop?: boolean; /** Fallback component to render if an error occurs */ - fallback?: React.ComponentType>; + fallback?: React.ComponentType>; /** called when an error occurs. The props property is only available if using .wrap */ onError?(data: { error: Error, errorInfo: React.ErrorInfo, props: T; }): void; /** Custom error message */ @@ -81,6 +81,7 @@ const ErrorBoundary = LazyComponent(() => { if (this.props.fallback) return ; diff --git a/src/plugins/accountPanelServerProfile/index.tsx b/src/plugins/accountPanelServerProfile/index.tsx index fcecffb17..1b468a6d8 100644 --- a/src/plugins/accountPanelServerProfile/index.tsx +++ b/src/plugins/accountPanelServerProfile/index.tsx @@ -85,7 +85,7 @@ export default definePlugin({ replace: "$&onRequestClose:$self.onPopoutClose," }, { - match: /(?<=.avatarWrapper,)/, + match: /(?<=\.avatarWrapper,)/, replace: "ref:$self.accountPanelRef,onContextMenu:$self.openAccountPanelContextMenu," } ] diff --git a/src/plugins/fullUserInChatbox/README.md b/src/plugins/fullUserInChatbox/README.md new file mode 100644 index 000000000..2401f5897 --- /dev/null +++ b/src/plugins/fullUserInChatbox/README.md @@ -0,0 +1,9 @@ +# Full User In Chatbox + +Adds the full user mention to the textbox + +Adds the avatar if you have mentioned avatars enabled + +Provides the full context menu to make it easy to access the users profile, and other common actions + +https://github.com/user-attachments/assets/cd9edb33-99c8-4c8d-b669-8cddd05f4b45 diff --git a/src/plugins/fullUserInChatbox/index.tsx b/src/plugins/fullUserInChatbox/index.tsx new file mode 100644 index 000000000..792f0419f --- /dev/null +++ b/src/plugins/fullUserInChatbox/index.tsx @@ -0,0 +1,47 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import ErrorBoundary from "@components/ErrorBoundary"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { findComponentByCodeLazy } from "@webpack"; +import { ReactNode } from "react"; + +const UserMentionComponent = findComponentByCodeLazy(".USER_MENTION)"); + +interface UserMentionComponentProps { + id: string; + channelId: string; + guildId: string; + OriginalComponent: ReactNode; +} + +export default definePlugin({ + name: "FullUserInChatbox", + description: "Makes the user mention in the chatbox have more functionalities, like left/right clicking", + authors: [Devs.sadan], + + patches: [ + { + find: ':"text":', + replacement: { + match: /(hidePersonalInformation\).+?)(if\(null!=\i\){.+?return \i)(?=})/, + replace: "$1return $self.UserMentionComponent({...arguments[0],OriginalComponent:(()=>{$2})()});" + } + } + ], + + UserMentionComponent: ErrorBoundary.wrap((props: UserMentionComponentProps) => ( + + ), { + fallback: ({ wrappedProps }) => wrappedProps.OriginalComponent + }) +});