parent
51b4748ba7
commit
39db491655
4 changed files with 11 additions and 3 deletions
|
|
@ -26,6 +26,10 @@ export const enum BadgePosition {
|
|||
}
|
||||
|
||||
export interface ProfileBadge {
|
||||
/**
|
||||
* Badge id, unused by vencord, required by discord
|
||||
*/
|
||||
id: string,
|
||||
/** The tooltip to show on hover. Required for image badges */
|
||||
description?: string;
|
||||
/** Custom component for the badge (tooltip not included) */
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { DONOR_ROLE_ID, VENCORD_GUILD_ID } from "@utils/constants";
|
|||
import { Button, GuildMemberStore } from "@webpack/common";
|
||||
|
||||
export const isDonor = (userId: string) => !!(
|
||||
BadgeAPI.getDonorBadges(userId)?.length > 0
|
||||
(BadgeAPI.getDonorBadges(userId)?.length ?? 0) > 0
|
||||
|| GuildMemberStore?.getMember(VENCORD_GUILD_ID, userId)?.roles.includes(DONOR_ROLE_ID)
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import { ContextMenuApi, Forms, Menu, Toasts, UserStore } from "@webpack/common"
|
|||
const CONTRIBUTOR_BADGE = "https://cdn.discordapp.com/emojis/1092089799109775453.png?size=64";
|
||||
|
||||
const ContributorBadge: ProfileBadge = {
|
||||
id: "vencord_contributor_badge",
|
||||
description: "Vencord Contributor",
|
||||
iconSrc: CONTRIBUTOR_BADGE,
|
||||
position: BadgePosition.START,
|
||||
|
|
@ -56,7 +57,7 @@ async function loadBadges(noCache = false) {
|
|||
|
||||
let intervalId: any;
|
||||
|
||||
function BadgeContextMenu({ badge }: { badge: ProfileBadge & BadgeUserArgs; }) {
|
||||
function BadgeContextMenu({ badge }: { badge: Omit<ProfileBadge, "id"> & BadgeUserArgs; }) {
|
||||
return (
|
||||
<Menu.Menu
|
||||
navId="vc-badge-context"
|
||||
|
|
@ -174,7 +175,8 @@ export default definePlugin({
|
|||
},
|
||||
|
||||
getDonorBadges(userId: string) {
|
||||
return DonorBadges[userId]?.map(badge => ({
|
||||
return DonorBadges[userId]?.map((badge, idx) => ({
|
||||
id: `vencord_donor_badge_${idx}`,
|
||||
iconSrc: badge.badge,
|
||||
description: badge.tooltip,
|
||||
position: BadgePosition.START,
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ function getBadges({ userId }: BadgeUserArgs): ProfileBadge[] {
|
|||
|
||||
return Object.entries(status).map(([platform, status]) => ({
|
||||
key: `vc-platform-indicator-${platform}`,
|
||||
id: `vc-platform-indicator-${platform}`,
|
||||
component: () => (
|
||||
<span className="vc-platform-indicator">
|
||||
<PlatformIcon
|
||||
|
|
@ -166,6 +167,7 @@ const PlatformIndicator = ({ user, small = false }: { user: User; small?: boolea
|
|||
};
|
||||
|
||||
const badge: ProfileBadge = {
|
||||
id: "vc_platform_indicator_wrapper",
|
||||
getBadges,
|
||||
position: BadgePosition.START,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue