Plugin

FullUserInChatbox

Makes the user mention in the chatbox have more functionalities, like left/right clicking

Shortcuts Utility
index.tsx
Download

Source

src/plugins/fullUserInChatbox/index.tsx
1import ErrorBoundary from "@components/ErrorBoundary";
2import { Devs } from "@utils/constants";
3import definePlugin from "@utils/types";
4import { findComponentByCodeLazy } from "@webpack";
5import { UserStore, useStateFromStores } from "@webpack/common";
6import { ReactNode } from "react";
7
8const UserMentionComponent = findComponentByCodeLazy(".USER_MENTION)");
9
10interface UserMentionComponentProps {
11 id: string;
12 channelId: string;
13 guildId: string;
14 originalComponent: () => ReactNode;
15}
16
17export default definePlugin({
18 name: "FullUserInChatbox",
19 description: "Makes the user mention in the chatbox have more functionalities, like left/right clicking",
20 tags: ["Shortcuts", "Utility"],
21 authors: [Devs.sadan],
22
23 patches: [
24 {
25 // Same find as RoleColorEverywhere chatbox mentions
26 find: '"text":"locked"',
27 replacement: {
28 match: /(hidePersonalInformation\).+?)(if\(null!=\i\){.+?return \i)(?=})/,
29 replace: "$1return $self.UserMentionComponent({...arguments[0],originalComponent:()=>{$2}});"
30 }
31 }
32 ],
33
34 UserMentionComponent: ErrorBoundary.wrap((props: UserMentionComponentProps) => {
35 const user = useStateFromStores([UserStore], () => UserStore.getUser(props.id));
36 if (user == null) {
37 return props.originalComponent();
38 }
39
40 return <UserMentionComponent
41 // This seems to be constant
42 className="mention"
43 userId={props.id}
44 channelId={props.channelId}
45 />;
46 }, {
47 fallback: ({ wrappedProps: { originalComponent } }) => originalComponent()
48 })
49});
50