const express = require('express'), path = require('path'), fs = require('fs'), WebSocket = require('ws') var app = express() const PORT = process.env.PORT || 8080 const staticpath = path.join(__dirname, 'static') const resourcePath = path.join(__dirname, "resources") const mainpage = resourcePath + '/mainPage.html' var lanyardData = undefined var discData = null app.use(express.static(staticpath)) app.listen(PORT, () => { console.log("Violet's Purgatory is now listening on port: " + PORT) }) app.get("/", (req, res) => { var html = fs.readFileSync(mainpage).toString() 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)"
}
}
var statusData = statuses[lanyardData.discord_status]
addedHTML += `
${statusData.text}`
addedHTML += ``
html = html.replace("{LANYARD}", addedHTML + "