0
0
mirror of https://github.com/yude-jp/yude.jp synced 2024-12-23 12:40:11 +09:00
yude.jp/pages/components/DiscordStatus.js

27 lines
984 B
JavaScript
Raw Normal View History

2021-05-24 01:22:46 +09:00
import React from "react";
2021-05-25 16:45:46 +09:00
const url = "https://discord.com/api/guilds/723409709306216498/widget.json";
2021-05-24 01:22:46 +09:00
const App = () => {
const [status, setStatus] = React.useState(0);
React.useEffect(() => {
fetch(url)
.then((r) => r.json())
2021-05-25 16:45:46 +09:00
.then((j) => setStatus(j.members[0].status))
2021-05-24 01:22:46 +09:00
}, []);
if (status === "online") {
return <div className="font-bold text-gray-700 rounded-full bg-green-500 flex w-5 h-5 items-center justify-center"></div>
}else{
if (status === "idle") {
return <div className="font-bold text-gray-700 rounded-full bg-yellow-500 flex w-5 h-5 items-center justify-center"></div>
}else{
if (status === "dnd") {
return <div className="font-bold text-gray-700 rounded-full bg-red-500 flex w-5 h-5 items-center justify-center"></div>
}else{
return <div className="font-bold text-gray-700 rounded-full bg-gray-500 flex w-5 h-5 items-center justify-center"></div>
}
}
}
};
export default App;