Skip to content

Commit

Permalink
fix: add padding for state
Browse files Browse the repository at this point in the history
Because Discord needs state string's length at least two, we add padding for the album's name is only one character
  • Loading branch information
aokblast committed Sep 22, 2023
1 parent 518e297 commit 822ef83
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 822ef83

Please sign in to comment.