2021-05-30 18:16:55 +09:00
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
import axios from 'axios';
|
2021-05-24 01:22:46 +09:00
|
|
|
|
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 = () => {
|
2021-05-30 18:16:55 +09:00
|
|
|
const [data, setData] = useState({ hits: [] });
|
|
|
|
useEffect(() => {
|
|
|
|
const fetchData = async () => {
|
|
|
|
const result = await axios(
|
|
|
|
'https://discord.com/api/guilds/723409709306216498/widget.json',
|
|
|
|
);
|
|
|
|
setData(result.data);
|
|
|
|
};
|
|
|
|
fetchData();
|
2021-05-24 01:22:46 +09:00
|
|
|
}, []);
|
2021-05-30 18:16:55 +09:00
|
|
|
const status = data.members && data.members[0].status;
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{
|
|
|
|
(() => {
|
|
|
|
if (status == "online"){
|
|
|
|
return <div className="z-1000 text-green-700 rounded-full bg-green-500 flex w-5 h-5"></div>
|
|
|
|
} else if (status == "idle"){
|
|
|
|
return <div className="z-1000 text-yellow-700 rounded-full bg-green-500 flex w-5 h-5"></div>
|
|
|
|
} else if (status == "dnd"){
|
|
|
|
return <div className="z-1000 text-yellow-700 rounded-full bg-red-500 flex w-5 h-5"></div>
|
|
|
|
} else {
|
|
|
|
return <div className="z-1000 text-gray-700 rounded-full bg-red-500 flex w-5 h-5"></div>
|
2021-05-24 01:22:46 +09:00
|
|
|
}
|
2021-05-30 18:16:55 +09:00
|
|
|
})()
|
2021-05-24 01:22:46 +09:00
|
|
|
}
|
2021-05-30 18:16:55 +09:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
2021-05-24 01:22:46 +09:00
|
|
|
|
|
|
|
export default App;
|