({});
React.useEffect(() => setBadges(fetchBadges(userId) ?? {}), [userId]);
if (!badges) return null;
const globalBadges: JSX.Element[] = [];
const badgeModal: JSX.Element[] = [];
Object.keys(badges).forEach(mod => {
if (mod.toLowerCase() === "vencord") return;
if (mod.toLowerCase() === "equicord") return;
if (mod.toLowerCase() === "suncord") return;
badges[mod].forEach(badge => {
if (typeof badge === "string") {
const fullNames = { "hunter": "Bug Hunter", "early": "Early User" };
badge = {
name: fullNames[badge as string] ? fullNames[badge as string] : badge,
badge: `${API_URL}badges/${mod}/${(badge as string).replace(mod, "").trim().split(" ")[0]}`
};
} else if (typeof badge === "object") badge.custom = true;
if (!showCustom() && badge.custom) return;
const cleanName = badge.name.replace(mod, "").trim();
const prefix = showPrefix() ? mod : "";
if (!badge.custom) badge.name = `${prefix} ${cleanName.charAt(0).toUpperCase() + cleanName.slice(1)}`;
globalBadges.push();
badgeModal.push();
});
});
badgeImages = badgeModal;
return (
openBadgeModal(UserStore.getUser(userId))}
>
{globalBadges}
);
};
const Badge: ProfileBadge = {
component: b => ,
position: BadgePosition.START,
shouldShow: userInfo => !!Object.keys(fetchBadges(userInfo.userId) ?? {}).length,
key: "GlobalBadges"
};
const showPrefix = () => Vencord.Settings.plugins.GlobalBadges.showPrefix;
const showCustom = () => Vencord.Settings.plugins.GlobalBadges.showCustom;
export default definePlugin({
name: "GlobalBadges",
description: "Adds global badges from other client mods",
authors: [Devs.HypedDomi, EquicordDevs.Wolfie],
start: () => addBadge(Badge),
stop: () => removeBadge(Badge),
options: {
showPrefix: {
type: OptionType.BOOLEAN,
description: "Shows the Mod as Prefix",
default: true,
restartNeeded: false
},
showCustom: {
type: OptionType.BOOLEAN,
description: "Show Custom Badges",
default: true,
restartNeeded: false
}
}
});
/*
Badge duping fix for modal lines below
L39 the value for everything below
L81 for not reusing globalbadges const
L100 for the size of the badges
L103 actual dupe fix
L109 is when clicking the badge open the modal
Everything below is related to the badge modal
*/
const cl = classNameFactory("vc-author-modal-");
const BadgeModalComponent = ({ name, img }: { name: string, img: string; }) => {
return (
{(tooltipProps: any) => (
)}
);
};
function BadgeModal({ user }: { user: User; }) {
return (
<>
{user.username}
{badgeImages.length ? (
{user.username} has {badgeImages.length} global badges.
) : (
{user.username} has no global badges.
)}
{!!badgeImages.length && (
{badgeImages}
)}
>
);
}
function openBadgeModal(user: User) {
openModal(modalprops =>
);
}