From 08ec7fadacd74d61d09ab3ff4e2c4db51f17879a Mon Sep 17 00:00:00 2001 From: Marie <8841466+Mar0xy@users.noreply.github.com> Date: Wed, 21 Apr 2021 03:31:44 +0200 Subject: [PATCH] Add Video support --- src/scripts/discord.js | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/scripts/discord.js b/src/scripts/discord.js index 1753baa..72e9069 100644 --- a/src/scripts/discord.js +++ b/src/scripts/discord.js @@ -21,16 +21,28 @@ const observer = (event, arg) => { const date = new Date(); let now = date.getTime() / 1000 | 0; let remaining = date.setSeconds(date.getSeconds() + (dsec - csec)); - rpc.setActivity({ - ...idleStatus, - ...{ - details: `Listening to ${mediaInfoModule.mediaInfo.title}`, - state: mediaInfoModule.mediaInfo.artist, - startTimestamp: parseInt(now), - endTimestamp: parseInt(remaining), - buttons: [{ label: "Play on Tidal", url: mediaInfoModule.mediaInfo.url }], - }, - }); + if (mediaInfoModule.mediaInfo.url) { + rpc.setActivity({ + ...idleStatus, + ...{ + details: `Listening to ${mediaInfoModule.mediaInfo.title}`, + state: mediaInfoModule.mediaInfo.artist, + startTimestamp: parseInt(now), + endTimestamp: parseInt(remaining), + buttons: [{ label: "Play on Tidal", url: mediaInfoModule.mediaInfo.url }], + }, + }); + } else { + rpc.setActivity({ + ...idleStatus, + ...{ + details: `Listening to ${mediaInfoModule.mediaInfo.title}`, + state: mediaInfoModule.mediaInfo.artist, + startTimestamp: parseInt(now), + endTimestamp: parseInt(remaining), + }, + }); + } } };