If we already sent this song to discord skip updating

This commit is contained in:
Wizzard 2024-08-06 08:50:57 -04:00
parent 39a8822ed0
commit 7f83c0f97b
1 changed files with 9 additions and 0 deletions

View File

@ -14,6 +14,7 @@ const extendedReconnectDelay = 90000;
let rp;
let startTime = Date.now();
let reconnecting = false;
let lastTrack = null;
function formatNumber(number) {
var x = number.split(".");
@ -92,6 +93,14 @@ async function updateStatus() {
return;
}
if (lastTrack && lastTrack.trackName === data.trackName && lastTrack.artist === data.artist) {
console.log("Same track, skipping update.");
setTimeout(updateStatus, updateInterval);
return;
}
lastTrack = data;
await rp.setActivity({
largeImageKey: data.cover !== "default_cover" ? data.cover : "default_cover",
largeImageText: `${data.playcount} plays.`,