forked from nin0/website
Added lanyard presence
This commit is contained in:
parent
67b548470f
commit
40da75ff84
5 changed files with 73 additions and 2 deletions
27
index.js
27
index.js
|
@ -1,4 +1,4 @@
|
|||
shouldLog = false;
|
||||
let shouldLog = false;
|
||||
function log(content) {
|
||||
if (shouldLog) console.log(content);
|
||||
}
|
||||
|
@ -20,6 +20,31 @@ function onUpdate(data) {
|
|||
pfp.style.borderColor = "var(--offline-color)";
|
||||
break;
|
||||
}
|
||||
// set presence
|
||||
log(data["activities"])
|
||||
let listening = false
|
||||
let content = ""
|
||||
data["activities"].forEach(presence => {
|
||||
if(presence["application_id"] == "463151177836658699" && presence["assets"]["small_text"] != "Paused") { // premid
|
||||
listening = true
|
||||
artist = presence["state"].substring(0, presence["state"].indexOf(" -"))
|
||||
if (artist == "") {
|
||||
artist = presence["state"]
|
||||
}
|
||||
content = `Listening to ${presence["details"]} - ${artist}`
|
||||
}
|
||||
if(presence["application_id"] == "1108588077900898414") { // vencord lastfm
|
||||
listening = true
|
||||
content = `Listening to ${presence["details"]} - ${presence["state"]}`
|
||||
}
|
||||
if(presence["type"] == 0 && presence["application_id"] != "463151177836658699" && presence["application_id"] != "1108588077900898414") { // generic playing status that isn't vencord lastfm or premid
|
||||
listening = false
|
||||
content = `Playing ${presence["name"]}`
|
||||
}
|
||||
});
|
||||
document.getElementById("presence").style.display = content == "" ? "none": "flex"
|
||||
document.getElementById("presence-content").innerText = content
|
||||
document.getElementById("presence-icon").src = listening ? "music.png" : "game.png"
|
||||
}
|
||||
LanyardWrapper.connectWebSocket("886685857560539176", onUpdate)
|
||||
.catch(err => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue