diff --git a/src/renderer/features/discord-rpc/use-discord-rpc.ts b/src/renderer/features/discord-rpc/use-discord-rpc.ts index 2b78b291d..633f2ad7a 100644 --- a/src/renderer/features/discord-rpc/use-discord-rpc.ts +++ b/src/renderer/features/discord-rpc/use-discord-rpc.ts @@ -26,6 +26,7 @@ const discordRpc = isElectron() ? window.api.discordRpc : null; type ActivityState = [QueueSong | undefined, number, PlayerStatus]; const MAX_FIELD_LENGTH = 127; +const MAX_URL_LENGTH = 256; const truncate = (field: string) => field.length <= MAX_FIELD_LENGTH ? field : field.substring(0, MAX_FIELD_LENGTH - 1) + '…'; @@ -163,13 +164,19 @@ export const useDiscordRpc = () => { ) { activity.stateUrl = 'https://www.last.fm/music/' + encodeURIComponent(song.artists[0].name); - activity.detailsUrl = + + const detailsUrl = 'https://www.last.fm/music/' + encodeURIComponent(song.albumArtists[0].name) + '/' + encodeURIComponent(song.album || '_') + '/' + encodeURIComponent(song.name); + + // The details URL has a max length, only set it if it doesn't exceed it + if (detailsUrl.length <= MAX_URL_LENGTH) { + activity.detailsUrl = detailsUrl; + } } if (