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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
---
const statusColors = {
online: "#43b581",
idle: "#faa61a",
dnd: "#f04747",
offline: "#747f8d",
};
const statusText = {
online: "Online",
idle: "Idle",
dnd: "Do Not Disturb",
offline: "Offline",
}
---
<section id="discord-status">
<img src="https://assets-global.website-files.com/6257adef93867e50d84d30e2/636e0a6ca814282eca7172c6_icon_clyde_white_RGB.svg" alt="Discord Avatar" />
<h2><span id="status-text"></span></h2>
</section>
<style>
#discord-status {
display: flex;
align-items: center;
padding: 15px;
border-radius: 10px;
color: white;
transition: background-color 0.3s ease-in-out;
}
#discord-status img {
width: 30px;
height: 30px;
border-radius: 50%;
margin-right: 20px;
}
#discord-status h2 {
font-size: 1.2rem;
}
#discord-status p {
font-size: 1rem;
opacity: 0.8;
}
</style>
<script>
const API_URL = "https://api.lanyard.rest/v1/users/246787839570739211";
fetch(API_URL)
.then(response => response.json())
.then(data => {
const discordUser = data.data.discord_user;
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 = document.getElementById("status-text");
statusSection.style.backgroundColor = statusColors[discordStatus];
statusTextElement.textContent = statusText[discordStatus];
})
.catch(error => console.error(error));
</script>
|