summaryrefslogtreecommitdiffstats
path: root/scripts/index.js
blob: a9ddf9362fbb79f430aec45ef10bbc73ae3a6ccb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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));
  }
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage