Skip to content

Commit

Permalink
Merge pull request #10 from andregamma/bugfix/discord-rpc-single-lett…
Browse files Browse the repository at this point in the history
…er-albums

fix: fix issue where one letter albums would crash the discordrpc plugin
  • Loading branch information
twnlink committed Mar 26, 2024
2 parents c1e20b6 + ce5db22 commit 314abbf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugins/DiscordRPC/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ client.then(() => {
const { item: currentlyPlaying, type: mediaType } = currentMediaItem;

const mediaURL = getMediaURLFromID(mediaType === "track" ? currentlyPlaying.album.cover : currentlyPlaying.imageId);
const largeImageTextContent = mediaType === "track" ? currentlyPlaying.album.title : currentlyPlaying.title;

const date = new Date();
const now = (date.getTime() / 1000) | 0;
Expand All @@ -42,7 +43,8 @@ client.then(() => {
"by " + currentlyPlaying.artists.map((a) => a.name).join(", ")
),
largeImageKey: mediaURL,
largeImageText: formatLongString(mediaType === 'track' ? currentlyPlaying.album.title : currentlyPlaying.title),
// Discord requires largeImageText to be at least 2 characters long. So we add a invisible space to the end of the string if it's only 1 character long.
largeImageText: largeImageTextContent.length >= 2 ? formatLongString(largeImageTextContent) : (largeImageTextContent + "‎"),
});
})
);
Expand Down

0 comments on commit 314abbf

Please sign in to comment.