From 410613726b7f2da85d653bbf0e9cb662f1abd32e Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 17 Nov 2022 00:21:13 +0100 Subject: Donor Badges && Add donate info to settings --- src/plugins/apiBadges.tsx | 93 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/apiBadges.tsx b/src/plugins/apiBadges.tsx index e26a7a1..831bf86 100644 --- a/src/plugins/apiBadges.tsx +++ b/src/plugins/apiBadges.tsx @@ -17,9 +17,16 @@ */ import { BadgePosition, ProfileBadge } from "../api/Badges"; +import DonateButton from "../components/DonateButton"; +import ErrorBoundary from "../components/ErrorBoundary"; +import { Flex } from "../components/Flex"; +import { Heart } from "../components/Heart"; import { Devs } from "../utils/constants"; import IpcEvents from "../utils/IpcEvents"; +import Logger from "../utils/Logger"; +import { closeModal, Modals, openModal } from "../utils/modal"; import definePlugin from "../utils/types"; +import { Forms, Margins } from "../webpack/common"; const CONTRIBUTOR_BADGE = "https://media.discordapp.net/stickers/1026517526106087454.webp"; @@ -40,6 +47,8 @@ const ContributorBadge: ProfileBadge = { onClick: () => VencordNative.ipc.invoke(IpcEvents.OPEN_EXTERNAL, "https://github.com/Vendicated/Vencord") }; +const DonorBadges = {} as Record>; + export default definePlugin({ name: "BadgeAPI", description: "API to add badges to users.", @@ -64,7 +73,89 @@ export default definePlugin({ } } ], - start() { + + async start() { Vencord.Api.Badges.addBadge(ContributorBadge); + const badges = await fetch("https://gist.githubusercontent.com/Vendicated/51a3dd775f6920429ec6e9b735ca7f01/raw/badges.csv").then(r => r.text()); + const lines = badges.trim().split("\n"); + if (lines.shift() !== "id,tooltip,image") { + new Logger("BadgeAPI").error("Invalid badges.csv file!"); + return; + } + for (const line of lines) { + const [id, tooltip, image] = line.split(","); + DonorBadges[id] = { image, tooltip }; + } }, + + addDonorBadge(badges: ProfileBadge[], userId: string) { + const badge = DonorBadges[userId]; + if (badge) { + badges.unshift({ + ...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