diff --git a/README.md b/README.md index 7368182..7c3a1f5 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,14 @@ If you don't want the default "`I'm not currently doing anything!`" as your idle If you'd like to show your global display name as well as your username, append the query param `showDisplayName=true` to the end of the URL. This is set to `false` by default. +### ___Avatar Decoration___ + +#### ___Hide Avatar Decoration___ +If you don't want people seeing your Avatar Decoration, append the query param `hideDecoration=true` to the end of the URL. Your Avatar Decoration is shown by default if you have one. + +#### ___Toogle Animated Avatar Decoration___ +If you have an Animated Avatar Decoration, append the query param `animatedDecoration=:bool` to the end of the URL, replacing `:bool` with `true` or `false`. This is set to `true` by default. + ### ___Hide Status___ If you don't want people seeing your status, append the query param `hideStatus=true` to the end of the URL. Your status is shown by default if you have one. diff --git a/src/LanyardTypes.ts b/src/LanyardTypes.ts index d09ef5c..4ea793c 100644 --- a/src/LanyardTypes.ts +++ b/src/LanyardTypes.ts @@ -38,6 +38,7 @@ export interface DiscordUser { global_name: string; display_name: string; clan: ClanTag | null; + avatar_decoration_data: AvatarDecoration | null; } export interface ClanTag { @@ -47,6 +48,12 @@ export interface ClanTag { identity_guild_id: number; } +export interface AvatarDecoration { + sku_id: string; + asset: string; + expires_at: number; +} + export interface Activity { type: number; state: string; diff --git a/src/renderCard.tsx b/src/renderCard.tsx index c187204..a491ee7 100644 --- a/src/renderCard.tsx +++ b/src/renderCard.tsx @@ -11,6 +11,7 @@ type Parameters = { bg?: string; clanbg?: string; animated?: string; + animatedDecoration?: string; hideDiscrim?: string; hideStatus?: string; hideTimestamp?: string; @@ -19,6 +20,7 @@ type Parameters = { hideActivity?: string; hideSpotify?: string; hideClan?: string; + hideDecoration?: string; ignoreAppId?: string; showDisplayName?: string; borderRadius?: string; @@ -74,10 +76,12 @@ const renderCard = async (body: LanyardTypes.Root, params: Parameters): Promise< let hideActivity = params.hideActivity ?? "false"; let hideSpotify = parseBool(params.hideSpotify); let hideClan = parseBool(params.hideClan); + let hideDecoration = parseBool(params.hideDecoration); let ignoreAppId = parseAppId(params.ignoreAppId); let hideDiscrim = parseBool(params.hideDiscrim); let showDisplayName = parseBool(params.showDisplayName); + if (!data.discord_user.avatar_decoration_data) hideDecoration = true; if (parseBool(params.hideDiscrim) || body.data.discord_user.discriminator === "0") hideDiscrim = true; if (!body.data.discord_user.clan) hideClan = true; if (data.activities[0]?.emoji?.animated) statusExtension = "gif"; @@ -115,6 +119,13 @@ const renderCard = async (body: LanyardTypes.Root, params: Parameters): Promise< ); } + let avatarDecoration: string; + if (data.discord_user.avatar_decoration_data) { + avatarDecoration = await encodeBase64( + `https://cdn.discordapp.com/avatar-decoration-presets/${data.discord_user.avatar_decoration_data.asset}.png?size=64&passthrough=${params.animatedDecoration || "true"}` + ); + } + switch (data.discord_status) { case "online": avatarBorderColor = "#43B581"; @@ -165,6 +176,19 @@ const renderCard = async (body: LanyardTypes.Root, params: Parameters): Promise< return ` + + +
+ ${hideDecoration || !data.discord_user.avatar_decoration_data ? "" : ` + + `} +