diff --git a/src/discord/MusicPlayer/Join.ts b/src/discord/MusicPlayer/Join.ts index b13b844..dabb0c3 100644 --- a/src/discord/MusicPlayer/Join.ts +++ b/src/discord/MusicPlayer/Join.ts @@ -61,7 +61,11 @@ const EMBEDS = { user: DiscordProvider.client.user }); - embed.setImage(track.thumbnails[0].url); + const highestResolutionThumbnail = track.thumbnails.reduce((prev, current) => (prev.height * prev.width > current.height * current.width) ? prev : current) + + if(highestResolutionThumbnail) + embed.setImage(highestResolutionThumbnail.url); + return embed; } } diff --git a/src/discord/MusicPlayer/NowPlaying.ts b/src/discord/MusicPlayer/NowPlaying.ts index 522149b..fae633e 100644 --- a/src/discord/MusicPlayer/NowPlaying.ts +++ b/src/discord/MusicPlayer/NowPlaying.ts @@ -14,7 +14,11 @@ const EMBEDS = { user: DiscordProvider.client.user }); - embed.setImage(track.thumbnails[0].url); + const highestResolutionThumbnail = track.thumbnails.reduce((prev, current) => (prev.height * prev.width > current.height * current.width) ? prev : current) + + if(highestResolutionThumbnail) + embed.setImage(highestResolutionThumbnail.url); + return embed; }, NO_MUSIC_PLAYING: (data: Message | Interaction) => { diff --git a/src/discord/MusicPlayer/Play.ts b/src/discord/MusicPlayer/Play.ts index 4586dcb..0a3e7a0 100644 --- a/src/discord/MusicPlayer/Play.ts +++ b/src/discord/MusicPlayer/Play.ts @@ -38,7 +38,12 @@ const EMBEDS = { description: `${track.title}`, user: (data instanceof Interaction) ? data.user : data.author }); - embed.setImage(track.thumbnails[0].url); + + const highestResolutionThumbnail = track.thumbnails.reduce((prev, current) => (prev.height * prev.width > current.height * current.width) ? prev : current) + + if(highestResolutionThumbnail) + embed.setImage(highestResolutionThumbnail.url); + return embed; }, ADDED_SONGS_QUEUE: (data: Message | Interaction, track: ValidTracks[]) => { diff --git a/src/discord/MusicPlayer/Search.ts b/src/discord/MusicPlayer/Search.ts index 1c5e8bc..5a0df9b 100644 --- a/src/discord/MusicPlayer/Search.ts +++ b/src/discord/MusicPlayer/Search.ts @@ -38,7 +38,12 @@ const EMBEDS = { description: `${track.title}`, user: (data instanceof Interaction) ? data.user : data.author }); - embed.setImage(track.thumbnails[0].url); + + const highestResolutionThumbnail = track.thumbnails.reduce((prev, current) => (prev.height * prev.width > current.height * current.width) ? prev : current) + + if(highestResolutionThumbnail) + embed.setImage(highestResolutionThumbnail.url); + return embed; }, USER_NOT_IN_VOICECHANNEL: (data: Message | Interaction) => {