From 3a7499644eeb45d770e8746783ff846637c66dee Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 3 Jul 2024 17:24:29 +0200 Subject: [PATCH] add pronouns, add nicks (kinda) --- src/plugins/editUsers/data.ts | 2 ++ src/plugins/editUsers/index.tsx | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/plugins/editUsers/data.ts b/src/plugins/editUsers/data.ts index 57d589fd4..7957d2ce8 100644 --- a/src/plugins/editUsers/data.ts +++ b/src/plugins/editUsers/data.ts @@ -20,6 +20,7 @@ export interface UserOverride { username: string; avatarUrl: string; bannerUrl: string; + pronouns: string; flags: OverrideFlags; } @@ -27,6 +28,7 @@ export const emptyOverride: UserOverride = Object.freeze({ username: "", avatarUrl: "", bannerUrl: "", + pronouns: "", flags: OverrideFlags.None, }); diff --git a/src/plugins/editUsers/index.tsx b/src/plugins/editUsers/index.tsx index 563a16fba..82e5130fe 100644 --- a/src/plugins/editUsers/index.tsx +++ b/src/plugins/editUsers/index.tsx @@ -66,14 +66,33 @@ export default definePlugin({ { match: /(?<=:).{0,10}\(\{id:this\.userId,banner/, replace: "$self.getBannerUrl(this.userId)||$&" + }, + { + match: /isUsingGuildMemberPronouns\(\)\{/, + replace: + "set pronouns(v){this._vcPronouns=v}" + + "get pronouns(){return $self.getPronouns(this.userId)||this._vcPronouns}" + + "isUsingGuildMemberPronouns(){" + }, + { + match: /\i\(this,"pronouns",void 0\),/, + replace: "" } ] + }, + { + find: '"GuildMemberStore"', + replacement: { + match: /getNick\(\i,(\i)\)\{/, + replace: "$& if ($self.shouldIgnoreNick($1)) return null;" + } } ], getUsername: (user: User) => getUserOverride(user.id).username, getAvatarUrl: (user: User) => getUserOverride(user.id).avatarUrl, getBannerUrl: (userId: string) => getUserOverride(userId).bannerUrl, + getPronouns: (userId: string) => getUserOverride(userId).pronouns, shouldIgnoreGuildAvatar(user: User) { const { avatarUrl, flags } = getUserOverride(user.id); @@ -91,5 +110,16 @@ export default definePlugin({ return true; return hasFlag(flags, OverrideFlags.DisableServerBanners); + }, + + shouldIgnoreNick(userId?: string) { + if (!userId) return false; + + const { username, flags } = getUserOverride(userId); + + if (username && !hasFlag(flags, OverrideFlags.PreferServerNicks)) + return true; + + return hasFlag(flags, OverrideFlags.DisableNicks); } });