diff --git a/plugins/copy-role-color/src/index.ts b/plugins/copy-role-color/src/index.ts index 8b9a635..ec3a6c2 100644 --- a/plugins/copy-role-color/src/index.ts +++ b/plugins/copy-role-color/src/index.ts @@ -8,10 +8,13 @@ import { showToast } from "@vendetta/ui/toasts"; import { applyPatches } from "@shared/lib/patcher"; function patchRolePill(): () => void { - const ThemedRolePill = findByName("ThemedRolePill", false); - if (!ThemedRolePill) return () => {}; + // Confirmed against decompiled current-build Discord source: the component is now just + // "RolePill" (at app/components_native/common/RolePill.tsx) - "ThemedRolePill" doesn't exist + // anywhere in it. Checking both names covers older builds that might still use the old one. + const RolePillComponent = findByName("RolePill", false) ?? findByName("ThemedRolePill", false); + if (!RolePillComponent) return () => {}; - return after("default", ThemedRolePill, (_args: any[], res: any) => { + return after("default", RolePillComponent, (_args: any[], res: any) => { try { if (!res?.props?.onPress) return; diff --git a/plugins/fake-profile-themes-and-effects/src/ui/color.ts b/plugins/fake-profile-themes-and-effects/src/ui/color.ts index 4357e6d..67805d8 100644 --- a/plugins/fake-profile-themes-and-effects/src/ui/color.ts +++ b/plugins/fake-profile-themes-and-effects/src/ui/color.ts @@ -41,8 +41,13 @@ export const useAvatarColors: ( export type Theme = "dark" | "light" | "midnight" | "darker"; +// The unguarded version of this line (`findByProps("getProfileTheme").getProfileTheme`) is what was +// crashing the whole plugin bundle at load time on at least one Discord build - accessing a property +// on the result of a failed findByProps throws immediately, outside any of this plugin's own +// try/catch, since it runs while the module is being evaluated, before onLoad is ever reached. export const getProfileTheme: (primaryColor: T) => T extends number ? Theme : null - = findByProps("getProfileTheme").getProfileTheme; + = (findByProps("getProfileTheme") as Record | undefined)?.getProfileTheme + ?? ((primaryColor: any) => (primaryColor == null ? null : "dark")) as any; export interface ThemeContext { theme: Theme; diff --git a/plugins/pronoun-db/src/index.tsx b/plugins/pronoun-db/src/index.tsx index 7823ad5..cf0ba32 100644 --- a/plugins/pronoun-db/src/index.tsx +++ b/plugins/pronoun-db/src/index.tsx @@ -5,16 +5,23 @@ import { findInReactTree } from "@vendetta/utils"; import PronounSection from "./ui/PronounSection"; import Settings from "./ui/Settings"; -const UserProfile = find((m: any) => m?.type?.name === "UserProfile"); +// Discord renamed the top-level profile component from "UserProfile" to "UserProfileContent" at +// some point (confirmed against decompiled current-build source) - checking both names covers +// whichever one a given Discord build actually uses. +const UserProfile = + find((m: any) => m?.type?.name === "UserProfileContent") ?? + find((m: any) => m?.type?.name === "UserProfile"); function patchProfile(): () => void { if (!UserProfile) return () => {}; return after("type", UserProfile, (_: any, res: any) => { try { + // Same story here - the bio card component is now named "UserProfileAboutMeCard", + // was "UserProfileBio" in older builds. const bioSection = findInReactTree(res, (r) => Array.isArray(r?.props?.children) && - r.props.children.some((c: any) => c?.type?.name === "UserProfileBio") + r.props.children.some((c: any) => c?.type?.name === "UserProfileAboutMeCard" || c?.type?.name === "UserProfileBio") ); const children = bioSection?.props?.children;