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