From 822ef83b24acbdd74687b227bf46be0df598f125 Mon Sep 17 00:00:00 2001 From: aokblast Date: Fri, 22 Sep 2023 22:31:14 +0800 Subject: [PATCH] fix: add padding for state Because Discord needs state string's length at least two, we add padding for the album's name is only one character --- src/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index ae98976..0a65b8f 100644 --- a/src/index.js +++ b/src/index.js @@ -106,11 +106,13 @@ async function SongChanged(core, data) { if(data.state === 'playing') { const { image_key, length, seek_position } = data.now_playing; const endTimestamp = Math.round((new Date().getTime() / 1000) + length - seek_position); + const state = (data.now_playing.three_line.line3.substring(0, 128) + + (data.now_playing.three_line.line3.length === 1 ? " " : "")) || undefined; const activity = { type: 2, // Doesn't work. (https://discord-api-types.dev/api/discord-api-types-v10/enum/ActivityType) details: data.now_playing.one_line.line1.substring(0, 128), - state: data.now_playing.three_line.line3.substring(0, 128), + state, endTimestamp, instance: false, largeImageKey: (image_key === PreviousAlbumArt.imageKey)? PreviousAlbumArt.imageUrl : 'roon_labs_logo',