From cdc6e1ca55d0f84074b94c654afe5dcb681c9cda Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Tue, 15 Oct 2024 00:00:22 -0700 Subject: initial commit --- scripts/index.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 scripts/index.js (limited to 'scripts') diff --git a/scripts/index.js b/scripts/index.js new file mode 100644 index 0000000..a9ddf93 --- /dev/null +++ b/scripts/index.js @@ -0,0 +1,30 @@ +function fetchDiscordStatus(userId) { + const API_URL = `https://api.lanyard.rest/v1/users/${userId}`; + + fetch(API_URL) + .then(response => response.json()) + .then(data => { + const discordStatus = data.data.discord_status; + + const statusColors = { + online: "#43b581", + idle: "#faa61a", + dnd: "#f04747", + offline: "#747f8d", + }; + + const statusText = { + online: "Online", + idle: "Idle", + dnd: "Do Not Disturb", + offline: "Offline", + }; + + const statusSection = document.getElementById(`discord-status`); + const statusTextElement = statusSection.querySelector(".status-text"); + + statusSection.style.backgroundColor = statusColors[discordStatus]; + statusTextElement.textContent = "Currently: " + statusText[discordStatus]; + }) + .catch(error => console.error("Error fetching Discord status:", error)); + } \ No newline at end of file -- cgit v1.2.3