diff --git a/index.js b/index.js index ee6970b..94f2a19 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ const express = require('express'), -path = require('path'), -fs = require('fs'), -WebSocket = require('ws') + path = require('path'), + fs = require('fs'), + WebSocket = require('ws') var app = express() @@ -24,34 +24,46 @@ app.listen(PORT, () => { app.get("/", (req, res) => { var html = fs.readFileSync(mainpage).toString() - var addedHTML = "

" + var addedHTML = "" - if (lanyardData && (lanyardData.spotify != null || lanyardData.activities[0] != undefined)) { - addedHTML += `Discord Status: ${lanyardData.spotify || '"' + lanyardData.activities[0].state + '"' || ""}` - } - - var statuses = { - "online": { - "text": "Online", - "color": "rgb(100, 255, 100)" - }, - "dnd": { - "text": "DND", - "color": "rgb(255, 100, 100)" - }, - "idle": { - "text": "Idle", - "color": "rgb(255, 255, 75)" - }, - "offline": { - "text": "Offline", - "color": "rgb(125, 125, 125)" + if (lanyardData) { + for (let index = 0; index < lanyardData.activities.length; index++) { + const activity = lanyardData.activities[index]; + console.log(activity) + if (activity.type == 2) { + addedHTML += `

Listening to on ${activity.name}: ${activity.details} (by ${activity.state})

` + } else if (activity.type == 4) { + addedHTML += `

"${lanyardData.activities[0].state}" - ${lanyardData.discord_user.display_name} ${new Date(Date.now()).getFullYear()}

` + } else if (activity.type == 0) { + addedHTML += `

Playing: ${activity.name}

` + } } - } - var statusData = statuses[lanyardData.discord_status] - addedHTML += `
${statusData.text}` - addedHTML += `` + var statuses = { + "online": { + "text": "Online", + "color": "rgb(100, 255, 100)" + }, + "dnd": { + "text": "DND", + "color": "rgb(255, 100, 100)" + }, + "idle": { + "text": "Idle", + "color": "rgb(255, 255, 75)" + }, + "offline": { + "text": "Offline", + "color": "rgb(125, 125, 125)" + } + } + var statusData = statuses[lanyardData.discord_status] + + addedHTML += `

${statusData.text}

` + addedHTML += `` + + console.log(lanyardData.activities) + } html = html.replace("{LANYARD}", addedHTML + "

") @@ -71,7 +83,7 @@ function beat(dur) { }, dur); } -lanyard.addEventListener("message", (res)=>{ +lanyard.addEventListener("message", (res) => { var data = JSON.parse(res.data) if (data.op == 1) { beat(data.d.heartbeat_interval) diff --git a/resources/mainPage.html b/resources/mainPage.html index e98544a..407f2b3 100644 --- a/resources/mainPage.html +++ b/resources/mainPage.html @@ -7,7 +7,7 @@ - + Violet's Purgatory @@ -34,16 +34,17 @@

Game & web developer

-

Warning: Not all services are up. Check hosting for more info.

+
+

Warning: Not all services are up. Check hosting for more info.

Stuff i'm hosting!

Socials

Pronouns


-

Fediverse: Fediverse: @Bingus_Violet@tech.lgbt

Ko-Fi: bingus_violet - Please - donate!

+ donate!

--> {LANYARD}