Skip to content

Commit

Permalink
added support for progress bar on newer versions of discord
Browse files Browse the repository at this point in the history
  • Loading branch information
SushantIndupuru authored and NextFire committed Sep 23, 2024
1 parent 609179f commit bfab69c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions music-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,19 @@ class AppleMusicDiscordRPC {
const props = await getMusicProps(this.appName);
console.log("props:", props);

let delta, end;
let delta, start, end;
if (props.duration) {
delta = (props.duration - props.playerPosition) * 1000;
end = Math.ceil(Date.now() + delta);
start = Math.ceil(Date.now() - props.playerPosition * 1000);
}

// EVERYTHING must be less than or equal to 128 chars long
const activity: Activity = {
// @ts-ignore: "listening to" is allowed in recent Discord versions
type: 2,
details: AppleMusicDiscordRPC.truncateString(props.name),
timestamps: { end },
timestamps: { start, end },
assets: { large_image: "appicon" },
};

Expand Down

0 comments on commit bfab69c

Please sign in to comment.