diff --git a/src/front/components/Lanyard/index.tsx b/src/front/components/Lanyard/index.tsx index 55ecc77..70781c3 100644 --- a/src/front/components/Lanyard/index.tsx +++ b/src/front/components/Lanyard/index.tsx @@ -16,6 +16,11 @@ const activityTypes: Record = { }; const getImageUrl = (activity: LanyardActivity, size: "large" | "small") => { + const width = size === "large" ? 120 : 40; + if (!activity.assets || !activity.assets.large_image) { + if (size === "large") return `https://dcdn.dstn.to/app-icons/${activity.application_id}?size=128`; + } + if (!activity.assets) return null; const image = activity.assets[`${size}_image`]; @@ -23,14 +28,15 @@ const getImageUrl = (activity: LanyardActivity, size: "large" | "small") => { if (!image) return null; if (image.startsWith("mp:external")) { - return `https://wsrv.nl/?w=${size === "large" ? 120 : 40}&url=https://${image.split("/").slice(3).join("/")}`.replace( - "1280x1280", - "160x160", - ); // last bit assumes tidal. + return `https://wsrv.nl/?w=${width}&url=https://media.discordapp.net/${image.slice(3)}` + } + + if (image.startsWith("mp:app-assets")) { + return `https://cdn.discordapp.com/${image.slice(3)}?size=${width}`; } if (image.startsWith("mp:")) { - return `https://cdn.discordapp.com/app-assets/${activity.application_id}/${image.slice(3)}.webp`; + return `https://cdn.discordapp.com/app-assets/${activity.application_id}/${image.slice(3)}.webp?size=${width}`; } }; @@ -68,7 +74,7 @@ export default () => { {" "}
-
{activityTypes[activity.type]}
+
{activityTypes[activity.type]}{!largeImage && ` ${activity.name}`}
{largeImage && (