diff --git a/src/api/Badges.ts b/src/api/Badges.ts
index 08f8648c..5f588274 100644
--- a/src/api/Badges.ts
+++ b/src/api/Badges.ts
@@ -17,7 +17,6 @@
*/
import ErrorBoundary from "@components/ErrorBoundary";
-import { User } from "discord-types/general";
import { ComponentType, HTMLProps } from "react";
import Plugins from "~plugins";
@@ -79,9 +78,9 @@ export function _getBadges(args: BadgeUserArgs) {
: badges.push({ ...badge, ...args });
}
}
- const donorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/_api/badges").default).getDonorBadges(args.user.id);
- const equicordDonorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/_api/badges").default).getEquicordDonorBadges(args.user.id);
- const suncordDonorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/_api/badges").default).getSuncordDonorBadges(args.user.id);
+ const donorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/_api/badges").default).getDonorBadges(args.userId);
+ const equicordDonorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/_api/badges").default).getEquicordDonorBadges(args.userId);
+ const suncordDonorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/_api/badges").default).getSuncordDonorBadges(args.userId);
if (donorBadges) badges.unshift(...donorBadges);
if (equicordDonorBadges) badges.unshift(...equicordDonorBadges);
if (suncordDonorBadges) badges.unshift(...suncordDonorBadges);
@@ -90,7 +89,7 @@ export function _getBadges(args: BadgeUserArgs) {
}
export interface BadgeUserArgs {
- user: User;
+ userId: string;
guildId: string;
}
diff --git a/src/equicordplugins/customAppIcons/index.tsx b/src/equicordplugins/customAppIcons/index.tsx
index 31139455..7cd19283 100644
--- a/src/equicordplugins/customAppIcons/index.tsx
+++ b/src/equicordplugins/customAppIcons/index.tsx
@@ -100,12 +100,12 @@ export default definePlugin({
<>
How to use?
-
- Go to { e.preventDefault(); closeAllModals(); FluxDispatcher.dispatch({ type: "USER_SETTINGS_MODAL_SET_SECTION", section: "Appearance" }); }}>Appearance Settings tab.
- Scroll down to "In-app Icons" and click on "Preview App Icon".
- And upload your own custom icon!
- You can only use links when you are uploading your Custom Icon.
- >
+
+ Go to { e.preventDefault(); closeAllModals(); FluxDispatcher.dispatch({ type: "USER_SETTINGS_MODAL_SET_SECTION", section: "Appearance" }); }}>Appearance Settings tab.
+ Scroll down to "In-app Icons" and click on "Preview App Icon".
+ And upload your own custom icon!
+ You can only use links when you are uploading your Custom Icon.
+ >
);
}
});
diff --git a/src/equicordplugins/friendshipRanks/index.tsx b/src/equicordplugins/friendshipRanks/index.tsx
index deb0ed82..eb666f61 100644
--- a/src/equicordplugins/friendshipRanks/index.tsx
+++ b/src/equicordplugins/friendshipRanks/index.tsx
@@ -121,9 +121,9 @@ function getBadgesToApply() {
description: rank.title,
component: () => getBadgeComponent(rank),
shouldShow: (info: BadgeUserArgs) => {
- if (!RelationshipStore.isFriend(info.user.id)) { return false; }
+ if (!RelationshipStore.isFriend(info.userId)) { return false; }
- const days = daysSince(RelationshipStore.getSince(info.user.id));
+ const days = daysSince(RelationshipStore.getSince(info.userId));
if (self[index + 1] == null) {
return days > rank.requirement;
diff --git a/src/equicordplugins/globalBadges/index.tsx b/src/equicordplugins/globalBadges/index.tsx
index 772eaa4c..2775ca46 100644
--- a/src/equicordplugins/globalBadges/index.tsx
+++ b/src/equicordplugins/globalBadges/index.tsx
@@ -20,7 +20,6 @@ import { addBadge, BadgePosition, ProfileBadge, removeBadge } from "@api/Badges"
import { Devs, EquicordDevs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import { React, Tooltip } from "@webpack/common";
-import { User } from "discord-types/general";
type CustomBadge = string | {
name: string;
@@ -67,9 +66,9 @@ const BadgeComponent = ({ name, img }: { name: string, img: string; }) => {
);
};
-const GlobalBadges = ({ user }: { user: User; }) => {
+const GlobalBadges = ({ userId }: { userId: string; }) => {
const [badges, setBadges] = React.useState({});
- React.useEffect(() => setBadges(fetchBadges(user.id) ?? {}), [user.id]);
+ React.useEffect(() => setBadges(fetchBadges(userId) ?? {}), [userId]);
if (!badges) return null;
const globalBadges: JSX.Element[] = [];
@@ -104,7 +103,7 @@ const GlobalBadges = ({ user }: { user: User; }) => {
const Badge: ProfileBadge = {
component: b => ,
position: BadgePosition.START,
- shouldShow: userInfo => !!Object.keys(fetchBadges(userInfo.user.id) ?? {}).length,
+ shouldShow: userInfo => !!Object.keys(fetchBadges(userInfo.userId) ?? {}).length,
key: "GlobalBadges"
};
diff --git a/src/plugins/_api/badges/index.tsx b/src/plugins/_api/badges/index.tsx
index b9de4b0f..b3e768a0 100644
--- a/src/plugins/_api/badges/index.tsx
+++ b/src/plugins/_api/badges/index.tsx
@@ -31,6 +31,7 @@ import { isEquicordPluginDev, isPluginDev } from "@utils/misc";
import { closeModal, Modals, openModal } from "@utils/modal";
import definePlugin from "@utils/types";
import { Forms, Toasts, UserStore } from "@webpack/common";
+import { User } from "discord-types/general";
const CONTRIBUTOR_BADGE = "https://vencord.dev/assets/favicon.png";
const EQUICORD_CONTRIBUTOR_BADGE = "https://i.imgur.com/rJDRtUB.png";
@@ -39,8 +40,8 @@ const ContributorBadge: ProfileBadge = {
description: "Vencord Contributor",
image: CONTRIBUTOR_BADGE,
position: BadgePosition.START,
- shouldShow: ({ user }) => isPluginDev(user.id),
- onClick: (_, { user }) => openContributorModal(user)
+ shouldShow: ({ userId }) => isPluginDev(userId),
+ onClick: (_, { userId }) => openContributorModal(UserStore.getUser(userId))
};
const EquicordContributorBadge: ProfileBadge = {
@@ -53,7 +54,7 @@ const EquicordContributorBadge: ProfileBadge = {
transform: "scale(0.9)" // The image is a bit too big compared to default badges
}
},
- shouldShow: ({ user }) => isEquicordPluginDev(user.id),
+ shouldShow: ({ userId }) => isEquicordPluginDev(userId),
link: "https://github.com/Equicord/Equicord"
};
@@ -91,7 +92,7 @@ export default definePlugin({
replacement: [
{
match: /&&(\i)\.push\(\{id:"premium".+?\}\);/,
- replace: "$&$1.unshift(...Vencord.Api.Badges._getBadges(arguments[0]));",
+ replace: "$&$1.unshift(...$self.getBadges(arguments[0]));",
},
{
// alt: "", aria-hidden: false, src: originalSrc
@@ -107,7 +108,7 @@ export default definePlugin({
// conditionally override their onClick with badge.onClick if it exists
{
match: /href:(\i)\.link/,
- replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, arguments[0]) }),$&"
+ replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, $1) }),$&"
}
]
},
@@ -122,11 +123,10 @@ export default definePlugin({
},
{
find: ".description,delay:",
- group: true,
replacement: [
{
match: /...(\i)\}=\(0,\i\.useUserProfileAnalyticsContext\)\(\);/,
- replace: "$& const VencordProps=$self.getProps($1); arguments[0].badges.unshift(...$self.getBadges($1));"
+ replace: "$&arguments[0].badges?.unshift(...$self.getBadges($1));"
},
{
// alt: "", aria-hidden: false, src: originalSrc
@@ -136,35 +136,17 @@ export default definePlugin({
},
{
match: /(?<=text:(\i)\.description,.{0,50})children:/,
- replace: "children:$1.component ? $self.renderBadgeComponent({ ...VencordProps, ...$1 }) :"
+ replace: "children:$1.component ? $self.renderBadgeComponent({ ...$1 }) :"
},
// conditionally override their onClick with badge.onClick if it exists
{
match: /href:(\i)\.link/,
- replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, VencordProps) }),$&"
+ replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, $1) }),$&"
}
]
}
],
- getProps(props: Record) {
- try {
- return { ...props, user: UserStore.getUser(props.userId) };
- } catch {
- return props;
- }
- },
-
- getBadges(props: { userId: string; guildId: string; }) {
- try {
- const { guildId, userId } = props;
- return _getBadges({ guildId, user: UserStore.getUser(userId) });
- } catch (e) {
- new Logger("BadgeAPI#hasBadges").error(e);
- return [];
- }
- },
-
toolboxActions: {
async "Refetch Badges"() {
await loadAllBadges(true);
@@ -182,6 +164,17 @@ export default definePlugin({
await loadAllBadges();
},
+ getBadges(props: { userId: string; user?: User; guildId: string; }) {
+ try {
+ props.userId ??= props.user?.id!;
+
+ return _getBadges(props);
+ } catch (e) {
+ new Logger("BadgeAPI#hasBadges").error(e);
+ return [];
+ }
+ },
+
renderBadgeComponent: ErrorBoundary.wrap((badge: ProfileBadge & BadgeUserArgs) => {
const Component = badge.component!;
return ;
diff --git a/src/plugins/platformIndicators/index.tsx b/src/plugins/platformIndicators/index.tsx
index 6d11073a..832e9890 100644
--- a/src/plugins/platformIndicators/index.tsx
+++ b/src/plugins/platformIndicators/index.tsx
@@ -129,9 +129,9 @@ const PlatformIndicator = ({ user, wantMargin = true, wantTopMargin = false, sma
};
const badge: ProfileBadge = {
- component: p => ,
+ component: p => ,
position: BadgePosition.START,
- shouldShow: userInfo => !!Object.keys(getStatus(userInfo.user.id) ?? {}).length,
+ shouldShow: userInfo => !!Object.keys(getStatus(userInfo.userId) ?? {}).length,
key: "indicator"
};
diff --git a/src/plugins/usrbg/index.tsx b/src/plugins/usrbg/index.tsx
index 9be3a610..32da95af 100644
--- a/src/plugins/usrbg/index.tsx
+++ b/src/plugins/usrbg/index.tsx
@@ -84,19 +84,6 @@ export default definePlugin({
}
},
- {
- find: /profileType:\i,pendingBanner:/,
- replacement: [
- {
- match: /(\i)\.premiumType/,
- replace: "$self.premiumHook($1)||$&"
- },
- {
- match: /function \i\((\i)\)\{/,
- replace: "$&$1.pendingBanner=$self.useBannerHook($1);"
- }
- ]
- },
{
find: "\"data-selenium-video-tile\":",
predicate: () => settings.store.voiceBackground,