mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat(richpresenceassets): add YouTube and custom image support (#7184)
This commit is contained in:
@@ -351,13 +351,21 @@ class RichPresenceAssets {
|
|||||||
* @returns {?string}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
smallImageURL({ format, size } = {}) {
|
smallImageURL({ format, size } = {}) {
|
||||||
return (
|
if (!this.smallImage) return null;
|
||||||
this.smallImage &&
|
if (this.smallImage.includes(':')) {
|
||||||
this.activity.presence.client.rest.cdn.AppAsset(this.activity.applicationId, this.smallImage, {
|
const [platform, id] = this.smallImage.split(':');
|
||||||
format,
|
switch (platform) {
|
||||||
size,
|
case 'mp':
|
||||||
})
|
return `https://media.discordapp.net/${id}`;
|
||||||
);
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.activity.presence.client.rest.cdn.AppAsset(this.activity.applicationId, this.smallImage, {
|
||||||
|
format,
|
||||||
|
size,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -367,11 +375,22 @@ class RichPresenceAssets {
|
|||||||
*/
|
*/
|
||||||
largeImageURL({ format, size } = {}) {
|
largeImageURL({ format, size } = {}) {
|
||||||
if (!this.largeImage) return null;
|
if (!this.largeImage) return null;
|
||||||
if (/^spotify:/.test(this.largeImage)) {
|
if (this.largeImage.includes(':')) {
|
||||||
return `https://i.scdn.co/image/${this.largeImage.slice(8)}`;
|
const [platform, id] = this.largeImage.split(':');
|
||||||
} else if (/^twitch:/.test(this.largeImage)) {
|
switch (platform) {
|
||||||
return `https://static-cdn.jtvnw.net/previews-ttv/live_user_${this.largeImage.slice(7)}.png`;
|
case 'mp':
|
||||||
|
return `https://media.discordapp.net/${id}`;
|
||||||
|
case 'spotify':
|
||||||
|
return `https://i.scdn.co/image/${id}`;
|
||||||
|
case 'youtube':
|
||||||
|
return `https://i.ytimg.com/vi/${id}/hqdefault_live.jpg`;
|
||||||
|
case 'twitch':
|
||||||
|
return `https://static-cdn.jtvnw.net/previews-ttv/live_user_${id}.png`;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.activity.presence.client.rest.cdn.AppAsset(this.activity.applicationId, this.largeImage, {
|
return this.activity.presence.client.rest.cdn.AppAsset(this.activity.applicationId, this.largeImage, {
|
||||||
format,
|
format,
|
||||||
size,
|
size,
|
||||||
|
|||||||
Reference in New Issue
Block a user