mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2024-11-15 01:34:38 +08:00
20 lines
546 B
JavaScript
20 lines
546 B
JavaScript
let server_addr = "mc.liteyuki.icu";
|
|
let api_url = "https://api.mcstatus.io/v2/status/java/" + server_addr;
|
|
|
|
let server_status = document.getElementById("now-online");
|
|
|
|
fetch(api_url)
|
|
.then(response => {
|
|
console.log(response);
|
|
return response.json();
|
|
})
|
|
.then(data => {
|
|
|
|
if (data.online){
|
|
server_status.textContent = "当前状态: 在线 " + data.players.online + " / " +data.players.max;
|
|
} else {
|
|
server_status.textContent = "当前状态: 服务器离线";
|
|
}
|
|
}
|
|
)
|