diff options
author | Vendicated <vendicated@riseup.net> | 2023-04-13 21:04:19 +0200 |
---|---|---|
committer | Vendicated <vendicated@riseup.net> | 2023-04-13 21:04:19 +0200 |
commit | c8817e805f9d0ea2b5cff370eb0c9e10b7a60f59 (patch) | |
tree | ba760e9e9ff56d214ab14c23a5002f283b3de5cd /src/api/Badges.ts | |
parent | c6f0d0763c1c1866aab55e32c4d1a1b8863c6b11 (diff) | |
download | Vencord-c8817e805f9d0ea2b5cff370eb0c9e10b7a60f59.tar.gz Vencord-c8817e805f9d0ea2b5cff370eb0c9e10b7a60f59.tar.bz2 Vencord-c8817e805f9d0ea2b5cff370eb0c9e10b7a60f59.zip |
Fix badges
Diffstat (limited to 'src/api/Badges.ts')
-rw-r--r-- | src/api/Badges.ts | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/api/Badges.ts b/src/api/Badges.ts index d4aabaf..9abaefe 100644 --- a/src/api/Badges.ts +++ b/src/api/Badges.ts @@ -29,11 +29,12 @@ export enum BadgePosition { export interface ProfileBadge { /** The tooltip to show on hover. Required for image badges */ - tooltip?: string; + description?: string; /** Custom component for the badge (tooltip not included) */ component?: ComponentType<ProfileBadge & BadgeUserArgs>; /** The custom image to use */ image?: string; + link?: string; /** Action to perform when you click the badge */ onClick?(): void; /** Should the user display this badge? */ @@ -69,17 +70,19 @@ export function removeBadge(badge: ProfileBadge) { * Inject badges into the profile badges array. * You probably don't need to use this. */ -export function inject(badgeArray: ProfileBadge[], args: BadgeUserArgs) { +export function _getBadges(args: BadgeUserArgs) { + const badges = [] as ProfileBadge[]; for (const badge of Badges) { if (!badge.shouldShow || badge.shouldShow(args)) { badge.position === BadgePosition.START - ? badgeArray.unshift({ ...badge, ...args }) - : badgeArray.push({ ...badge, ...args }); + ? badges.unshift({ ...badge, ...args }) + : badges.push({ ...badge, ...args }); } } - (Plugins.BadgeAPI as any).addDonorBadge(badgeArray, args.user.id); + const donorBadge = (Plugins.BadgeAPI as any).getDonorBadge(args.user.id); + if (donorBadge) badges.unshift(donorBadge); - return badgeArray; + return badges; } export interface BadgeUserArgs { |