From bbb641b378c9fd1b7a9fa3a9770a14198437c03f Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Sat, 15 Mar 2025 19:25:05 -0400 Subject: [PATCH] Make Donor Badge Api Based --- src/components/VencordSettings/VencordTab.tsx | 12 ++++++------ src/plugins/_api/badges/index.tsx | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/components/VencordSettings/VencordTab.tsx b/src/components/VencordSettings/VencordTab.tsx index adcee0e5..f95089e8 100644 --- a/src/components/VencordSettings/VencordTab.tsx +++ b/src/components/VencordSettings/VencordTab.tsx @@ -120,14 +120,14 @@ function EquicordSettings() { return ( <SettingsTab title="Equicord Settings"> - {(isDonor(user?.id) || isVCDonor(user?.id)) ? ( + {(isEquicordDonor(user?.id) || isVencordDonor(user?.id)) ? ( <SpecialCard title="Donations" subtitle="Thank you for donating!" description={ - isDonor(user?.id) && isVCDonor(user?.id) + isEquicordDonor(user?.id) && isVencordDonor(user?.id) ? "All Vencord users can see your Vencord donor badge, and Equicord users can see your Equicord donor badge. To change your Vencord donor badge, contact @vending.machine. For your Equicord donor badge, make a ticket in Equicord's server." - : isVCDonor(user?.id) + : isVencordDonor(user?.id) ? "All Vencord users can see your badge! You can change it at any time by messaging @vending.machine." : "All Equicord users can see your badge! You can change it at any time by making a ticket in Equicord's server." } @@ -345,13 +345,13 @@ function DonateButtonComponent() { ); } -function isVCDonor(userId: string): boolean { +function isVencordDonor(userId: string): boolean { const donorBadges = BadgeAPI.getDonorBadges(userId); return GuildMemberStore.getMember(VC_GUILD_ID, userId)?.roles.includes(VC_DONOR_ROLE_ID) || !!donorBadges; } -function isDonor(userId: string): boolean { - const donorBadges = BadgeAPI.getDonorBadges(userId); +export function isEquicordDonor(userId: string): boolean { + const donorBadges = BadgeAPI.getEquicordDonorBadges(userId); return GuildMemberStore.getMember(GUILD_ID, userId)?.roles.includes(DONOR_ROLE_ID) || !!donorBadges; } diff --git a/src/plugins/_api/badges/index.tsx b/src/plugins/_api/badges/index.tsx index 4464f2b2..8b5ff999 100644 --- a/src/plugins/_api/badges/index.tsx +++ b/src/plugins/_api/badges/index.tsx @@ -24,6 +24,7 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Flex } from "@components/Flex"; import { Heart } from "@components/Heart"; import { openContributorModal } from "@components/PluginSettings/ContributorModal"; +import { isEquicordDonor } from "@components/VencordSettings/VencordTab"; import { Devs } from "@utils/constants"; import { Logger } from "@utils/Logger"; import { Margins } from "@utils/margins"; @@ -35,6 +36,7 @@ import { User } from "discord-types/general"; const CONTRIBUTOR_BADGE = "https://vencord.dev/assets/favicon.png"; const EQUICORD_CONTRIBUTOR_BADGE = "https://i.imgur.com/57ATLZu.png"; +const EQUICORD_DONOR_BADGE = "https://cdn.nest.rip/uploads/78cb1e77-b7a6-4242-9089-e91f866159bf.png"; const ContributorBadge: ProfileBadge = { description: "Vencord Contributor", @@ -52,6 +54,17 @@ const EquicordContributorBadge: ProfileBadge = { onClick: (_, { userId }) => openContributorModal(UserStore.getUser(userId)) }; +const EquicordDonorBadge: ProfileBadge = { + description: "Equicord Donor", + image: EQUICORD_DONOR_BADGE, + position: BadgePosition.START, + shouldShow: ({ userId }) => { + const donorBadges = EquicordDonorBadges[userId]?.map(badge => badge.badge); + const hasDonorBadge = donorBadges?.includes("https://cdn.nest.rip/uploads/78cb1e77-b7a6-4242-9089-e91f866159bf.png"); + return isEquicordDonor(userId) && !hasDonorBadge; + } +}; + let DonorBadges = {} as Record<string, Array<Record<"tooltip" | "badge", string>>>; let EquicordDonorBadges = {} as Record<string, Array<Record<"tooltip" | "badge", string>>>; @@ -118,6 +131,7 @@ export default definePlugin({ async start() { Vencord.Api.Badges.addProfileBadge(ContributorBadge); Vencord.Api.Badges.addProfileBadge(EquicordContributorBadge); + Vencord.Api.Badges.addProfileBadge(EquicordDonorBadge); await loadAllBadges(); },