diff options
author | Vendicated <vendicated@riseup.net> | 2023-04-29 02:06:52 +0200 |
---|---|---|
committer | Vendicated <vendicated@riseup.net> | 2023-04-29 02:06:52 +0200 |
commit | a2e03084b001a154bf1b33b213480028bb2d4e59 (patch) | |
tree | 85dfe8c491b93c8b2b79b29cbc737b6d10b06e71 /src/plugins | |
parent | ec72b4c91d422fa95ee93d71f3be839fdad679de (diff) | |
download | Vencord-a2e03084b001a154bf1b33b213480028bb2d4e59.tar.gz Vencord-a2e03084b001a154bf1b33b213480028bb2d4e59.tar.bz2 Vencord-a2e03084b001a154bf1b33b213480028bb2d4e59.zip |
BadgeAPI: Add support for multiple donor badges
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/apiBadges.tsx | 139 |
1 files changed, 68 insertions, 71 deletions
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<string, Pick<ProfileBadge, "image" | "description">>; +const DonorBadges = {} as Record<string, Pick<ProfileBadge, "image" | "description">[]>; 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 => ( - <ErrorBoundary noop onError={() => { - closeModal(modalKey); - VencordNative.ipc.invoke(IpcEvents.OPEN_EXTERNAL, "https://github.com/sponsors/Vendicated"); - }}> - <Modals.ModalRoot {...props}> - <Modals.ModalHeader> - <Flex style={{ width: "100%", justifyContent: "center" }}> - <Forms.FormTitle - tag="h2" - style={{ - width: "100%", - textAlign: "center", - margin: 0 - }} - > - <Heart /> - Vencord Donor - </Forms.FormTitle> - </Flex> - </Modals.ModalHeader> - <Modals.ModalContent> - <Flex> - <img - role="presentation" - src="https://cdn.discordapp.com/emojis/1026533070955872337.png" - alt="" - style={{ margin: "auto" }} - /> - <img - role="presentation" - src="https://cdn.discordapp.com/emojis/1026533090627174460.png" - alt="" - style={{ margin: "auto" }} - /> - </Flex> - <div style={{ padding: "1em" }}> - <Forms.FormText> - This Badge is a special perk for Vencord Donors - </Forms.FormText> - <Forms.FormText className={Margins.top20}> - Please consider supporting the development of Vencord by becoming a donor. It would mean a lot!! - </Forms.FormText> - </div> - </Modals.ModalContent> - <Modals.ModalFooter> - <Flex style={{ width: "100%", justifyContent: "center" }}> - <DonateButton /> - </Flex> - </Modals.ModalFooter> - </Modals.ModalRoot> - </ErrorBoundary> - )); - }, - }; - } + 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 => ( + <ErrorBoundary noop onError={() => { + closeModal(modalKey); + VencordNative.ipc.invoke(IpcEvents.OPEN_EXTERNAL, "https://github.com/sponsors/Vendicated"); + }}> + <Modals.ModalRoot {...props}> + <Modals.ModalHeader> + <Flex style={{ width: "100%", justifyContent: "center" }}> + <Forms.FormTitle + tag="h2" + style={{ + width: "100%", + textAlign: "center", + margin: 0 + }} + > + <Heart /> + Vencord Donor + </Forms.FormTitle> + </Flex> + </Modals.ModalHeader> + <Modals.ModalContent> + <Flex> + <img + role="presentation" + src="https://cdn.discordapp.com/emojis/1026533070955872337.png" + alt="" + style={{ margin: "auto" }} + /> + <img + role="presentation" + src="https://cdn.discordapp.com/emojis/1026533090627174460.png" + alt="" + style={{ margin: "auto" }} + /> + </Flex> + <div style={{ padding: "1em" }}> + <Forms.FormText> + This Badge is a special perk for Vencord Donors + </Forms.FormText> + <Forms.FormText className={Margins.top20}> + Please consider supporting the development of Vencord by becoming a donor. It would mean a lot!! + </Forms.FormText> + </div> + </Modals.ModalContent> + <Modals.ModalFooter> + <Flex style={{ width: "100%", justifyContent: "center" }}> + <DonateButton /> + </Flex> + </Modals.ModalFooter> + </Modals.ModalRoot> + </ErrorBoundary> + )); + }, + })); } }); |