index.tsx
index.tsx
"@api/Badges";
import definePlugin, { OptionType } from "@utils/types";
import { React, Tooltip } from "@webpack/common";
interface BadgeCache {
badges: {
[mod: string]: CustomBadge[];
};
expires: number;
}
Object.keys(badges).forEach(mod => {
if (mod.toLowerCase() === "vencord") 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(<BadgeComponent name={badge.name}
img={badge.badge} />);
});
});
return (
<div
className="vc-global-badges"
style={{
display: "flex",
alignItems: "center"
}}
>
{globalBadges}
</div>
);
};
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
}
}
});