From 7b13b9a53ea92c337b9840c0050c6a47266efdcc Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 28 Apr 2023 19:15:07 +0200 Subject: PronounDB: Fix not working in profiles --- src/plugins/pronoundb/index.ts | 65 +++++++++++------------------------------- 1 file changed, 16 insertions(+), 49 deletions(-) (limited to 'src/plugins/pronoundb/index.ts') diff --git a/src/plugins/pronoundb/index.ts b/src/plugins/pronoundb/index.ts index 59ade8d..bc01e1d 100644 --- a/src/plugins/pronoundb/index.ts +++ b/src/plugins/pronoundb/index.ts @@ -19,20 +19,16 @@ import "./styles.css"; import { Devs } from "@utils/constants"; -import definePlugin, { OptionType } from "@utils/types"; +import definePlugin from "@utils/types"; import PronounsAboutComponent from "./components/PronounsAboutComponent"; import { CompactPronounsChatComponentWrapper, PronounsChatComponentWrapper } from "./components/PronounsChatComponent"; -import PronounsProfileWrapper from "./components/PronounsProfileWrapper"; - -export enum PronounsFormat { - Lowercase = "LOWERCASE", - Capitalized = "CAPITALIZED" -} +import { useProfilePronouns } from "./pronoundbUtils"; +import { settings } from "./settings"; export default definePlugin({ name: "PronounDB", - authors: [Devs.Tyman, Devs.TheKodeToad], + authors: [Devs.Tyman, Devs.TheKodeToad, Devs.Ven], description: "Adds pronouns to user messages using pronoundb", patches: [ // Add next to username (compact mode) @@ -51,59 +47,30 @@ export default definePlugin({ replace: "[$1, $self.PronounsChatComponentWrapper(e)]" } }, - // Hijack the discord pronouns section and add a wrapper around the text section + // Patch the profile popout username header to use our pronoun hook instead of Discord's pronouns { - find: ".Messages.BOT_PROFILE_SLASH_COMMANDS", + find: ".userTagNoNickname", replacement: { - match: /\(0,.\.jsx\)\((?\i\..),(?{currentPronouns.+?:(?\i)\.pronouns.+?})\)/, - replace: "$&&$self.PronounsProfileWrapper($,$,$)" + match: /=(\i)\.pronouns/, + replace: "=$self.useProfilePronouns($1.user.id)" } }, - // Force enable pronouns component ignoring the experiment value + // Patch the profile modal username header to use our pronoun hook instead of Discord's pronouns { - find: ".Messages.USER_POPOUT_PRONOUNS", + find: ".USER_PROFILE_ACTIVITY", replacement: { - match: /\.showPronouns/, - replace: ".showPronouns||true" + match: /\).showPronouns/, + replace: ").showPronouns||true;if(arguments[0].displayProfile)arguments[0].displayProfile.pronouns=$self.useProfilePronouns(arguments[0].user.id)" } } ], - options: { - pronounsFormat: { - type: OptionType.SELECT, - description: "The format for pronouns to appear in chat", - options: [ - { - label: "Lowercase", - value: PronounsFormat.Lowercase, - default: true - }, - { - label: "Capitalized", - value: PronounsFormat.Capitalized - } - ] - }, - showSelf: { - type: OptionType.BOOLEAN, - description: "Enable or disable showing pronouns for the current user", - default: true - }, - showInMessages: { - type: OptionType.BOOLEAN, - description: "Show in messages", - default: true - }, - showInProfile: { - type: OptionType.BOOLEAN, - description: "Show in profile", - default: true - } - }, + settings, + settingsAboutComponent: PronounsAboutComponent, + // Re-export the components on the plugin object so it is easily accessible in patches PronounsChatComponentWrapper, CompactPronounsChatComponentWrapper, - PronounsProfileWrapper + useProfilePronouns }); -- cgit