From a2e03084b001a154bf1b33b213480028bb2d4e59 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 29 Apr 2023 02:06:52 +0200 Subject: BadgeAPI: Add support for multiple donor badges --- src/plugins/apiBadges.tsx | 139 +++++++++++++++++++++++----------------------- 1 file changed, 68 insertions(+), 71 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/apiBadges.tsx b/src/plugins/apiBadges.tsx index 57c5b38..a156b63 100644 --- a/src/plugins/apiBadges.tsx +++ b/src/plugins/apiBadges.tsx @@ -48,7 +48,7 @@ const ContributorBadge: ProfileBadge = { link: "https://github.com/Vendicated/Vencord" }; -const DonorBadges = {} as Record>; +const DonorBadges = {} as Record[]>; export default definePlugin({ name: "BadgeAPI", @@ -97,78 +97,75 @@ 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 { - ...badge, - position: BadgePosition.START, - props: { - style: { - borderRadius: "50%", - transform: "scale(0.9)" // The image is a bit too big compared to default badges - } - }, - onClick() { - const modalKey = openModal(props => ( - { - closeModal(modalKey); - VencordNative.ipc.invoke(IpcEvents.OPEN_EXTERNAL, "https://github.com/sponsors/Vendicated"); - }}> - - - - - - Vencord Donor - - - - - - - - -
- - This Badge is a special perk for Vencord Donors - - - Please consider supporting the development of Vencord by becoming a donor. It would mean a lot!! - -
-
- - - - - -
-
- )); - }, - }; - } + getDonorBadges(userId: string) { + return DonorBadges[userId]?.map(badge => ({ + ...badge, + position: BadgePosition.START, + props: { + style: { + borderRadius: "50%", + transform: "scale(0.9)" // The image is a bit too big compared to default badges + } + }, + onClick() { + const modalKey = openModal(props => ( + { + closeModal(modalKey); + VencordNative.ipc.invoke(IpcEvents.OPEN_EXTERNAL, "https://github.com/sponsors/Vendicated"); + }}> + + + + + + Vencord Donor + + + + + + + + +
+ + This Badge is a special perk for Vencord Donors + + + Please consider supporting the development of Vencord by becoming a donor. It would mean a lot!! + +
+
+ + + + + +
+
+ )); + }, + })); } }); -- cgit