mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 10:11:46 +00:00
fix(discord): restore Hangul Filler patch for short fields in Rich Presence
Re-added the original workaround that pads title, artist, and album fields with the Hangul Filler character (\u3164) if their length is less than 2. This prevents Discord Rich Presence from displaying empty or missing fields when song info is very short.
This commit is contained in:
@ -139,6 +139,19 @@ function sendActivityToDiscord(songInfo: SongInfo, config: DiscordPluginConfig)
|
||||
if (!info.rpc || !info.ready) {
|
||||
return;
|
||||
}
|
||||
// Song information changed, so lets update the rich presence
|
||||
// @see https://discord.com/developers/docs/topics/gateway#activity-object
|
||||
// not all options are transfered through https://github.com/discordjs/RPC/blob/6f83d8d812c87cb7ae22064acd132600407d7d05/src/client.js#L518-530
|
||||
const hangulFillerUnicodeCharacter = '\u3164'; // This is an empty character
|
||||
const paddedInfoKeys: (keyof SongInfo)[] = ['title', 'artist', 'album'];
|
||||
for (const key of paddedInfoKeys) {
|
||||
const keyLength = (songInfo[key] as string)?.length;
|
||||
if (keyLength < 2) {
|
||||
(songInfo[key] as string) += hangulFillerUnicodeCharacter.repeat(
|
||||
2 - keyLength,
|
||||
);
|
||||
}
|
||||
}
|
||||
let buttons: GatewayActivityButton[] | undefined = [];
|
||||
if (config.playOnYouTubeMusic) {
|
||||
buttons.push({
|
||||
|
||||
Reference in New Issue
Block a user