diff options
| author | Pinapelz <yukais@pinapelz.com> | 2024-10-15 00:00:22 -0700 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2024-10-15 00:00:22 -0700 |
| commit | cdc6e1ca55d0f84074b94c654afe5dcb681c9cda (patch) | |
| tree | d4ddddd243f35fa3dac06504aca203f45dc9a1b3 /scripts | |
initial commit
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/index.js | 30 |
1 files changed, 30 insertions, 0 deletions
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 |
