BadgeAPI: Add support for multiple donor badges
This commit is contained in:
parent
ec72b4c91d
commit
a2e03084b0
2 changed files with 70 additions and 73 deletions
|
@ -79,8 +79,8 @@ export function _getBadges(args: BadgeUserArgs) {
|
|||
: badges.push({ ...badge, ...args });
|
||||
}
|
||||
}
|
||||
const donorBadge = (Plugins.BadgeAPI as any).getDonorBadge(args.user.id);
|
||||
if (donorBadge) badges.unshift(donorBadge);
|
||||
const donorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/apiBadges").default).getDonorBadges(args.user.id);
|
||||
if (donorBadges) badges.unshift(...donorBadges);
|
||||
|
||||
return badges;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ const ContributorBadge: ProfileBadge = {
|
|||
link: "https://github.com/Vendicated/Vencord"
|
||||
};
|
||||
|
||||
const DonorBadges = {} as Record<string, Pick<ProfileBadge, "image" | "description">>;
|
||||
const DonorBadges = {} as Record<string, Pick<ProfileBadge, "image" | "description">[]>;
|
||||
|
||||
export default definePlugin({
|
||||
name: "BadgeAPI",
|
||||
|
@ -97,14 +97,12 @@ export default definePlugin({
|
|||
}
|
||||
for (const line of lines) {
|
||||
const [id, description, image] = line.split(",");
|
||||
DonorBadges[id] = { image, description };
|
||||
(DonorBadges[id] ??= []).push({ image, description });
|
||||
}
|
||||
},
|
||||
|
||||
getDonorBadge(userId: string) {
|
||||
const badge = DonorBadges[userId];
|
||||
if (badge) {
|
||||
return {
|
||||
getDonorBadges(userId: string) {
|
||||
return DonorBadges[userId]?.map(badge => ({
|
||||
...badge,
|
||||
position: BadgePosition.START,
|
||||
props: {
|
||||
|
@ -168,7 +166,6 @@ export default definePlugin({
|
|||
</ErrorBoundary>
|
||||
));
|
||||
},
|
||||
};
|
||||
}
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue