Skip to content

Commit e1f6d5b

Browse files
authored
fix(discord-plugin): handle album name padding if length < 2 (#2903)
1 parent b6b6078 commit e1f6d5b

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/plugins/discord/main.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,14 @@ export const backend = createBackend<
154154
// @see https://discord.com/developers/docs/topics/gateway#activity-object
155155
// not all options are transfered through https://github.com/discordjs/RPC/blob/6f83d8d812c87cb7ae22064acd132600407d7d05/src/client.js#L518-530
156156
const hangulFillerUnicodeCharacter = '\u3164'; // This is an empty character
157-
if (songInfo.title.length < 2) {
158-
songInfo.title += hangulFillerUnicodeCharacter.repeat(
159-
2 - songInfo.title.length,
160-
);
161-
}
162-
if (songInfo.artist.length < 2) {
163-
songInfo.artist += hangulFillerUnicodeCharacter.repeat(
164-
2 - songInfo.title.length,
165-
);
157+
const paddedInfoKeys: (keyof SongInfo)[] = ['title', 'artist', 'album'];
158+
for (const key of paddedInfoKeys) {
159+
const keyLength = (songInfo[key] as string)?.length;
160+
if (keyLength < 2) {
161+
(songInfo[key] as string) += hangulFillerUnicodeCharacter.repeat(
162+
2 - keyLength,
163+
);
164+
}
166165
}
167166

168167
// see https://github.com/th-ch/youtube-music/issues/1664

0 commit comments

Comments
 (0)