feat: add discord cdn support for app images
This commit is contained in:
@@ -98,18 +98,22 @@ interface DiscordActivity {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveDiscordAsset(image: string | undefined): string {
|
function resolveDiscordAsset(applicationId: string | undefined, image: string | undefined): string {
|
||||||
if (!image) return "";
|
if (!image) return "";
|
||||||
|
|
||||||
if (image.startsWith("mp:external/")) {
|
if (image.startsWith("mp:external/")) {
|
||||||
const httpsIndex = image.indexOf("/https/");
|
const httpsIndex = image.indexOf("/https/");
|
||||||
if (httpsIndex !== -1) {
|
if (httpsIndex !== -1) {
|
||||||
const after = image.slice(httpsIndex + "/https/".length);
|
return `https://${image.slice(httpsIndex + "/https/".length)}`;
|
||||||
return `https://${after}`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (/^\d+$/.test(image) || image.startsWith("spotify:")) return "";
|
if (image.startsWith("spotify:"))
|
||||||
|
return "";
|
||||||
|
|
||||||
|
|
||||||
|
if (applicationId && image)
|
||||||
|
return `https://cdn.discordapp.com/app-assets/${applicationId}/${image}.png`;
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user