This commit is contained in:
Ally Founder 2026-08-01 12:06:15 -04:00
parent 53af7ce785
commit cf1f1fec36
3 changed files with 21 additions and 6 deletions

View file

@ -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;

View file

@ -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: <T extends number | null | undefined>(primaryColor: T) => T extends number ? Theme : null
= findByProps("getProfileTheme").getProfileTheme;
= (findByProps("getProfileTheme") as Record<string, any> | undefined)?.getProfileTheme
?? ((primaryColor: any) => (primaryColor == null ? null : "dark")) as any;
export interface ThemeContext {
theme: Theme;

View file

@ -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;