From ce5ad0eec758cbdd6b452e4bfda05b67b52bf8ef Mon Sep 17 00:00:00 2001 From: aokblast Date: Fri, 22 Sep 2023 22:19:52 +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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index ae98976..760b847 100644 --- a/src/index.js +++ b/src/index.js @@ -106,11 +106,14 @@ 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 === undefined ? undefined : + data.now_playing.three_line.line3.substring(0, 128) + + (data.now_playing.three_line.line3.length === 1 ? " " : data)); 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',