const config = require("../config.json")

async function fetchServerStatus() {
    const response = await fetch(`https://api.mcsrvstat.us/3/${config.minecraft.server.host}:${config.minecraft.server.port}`)
    const json = await response.json()
    return {
        online: json.online,
        players: {
            online: json.players.online || 0,
            max: json.players.max || 0
        }
    }
    
}

module.exports = {
    fetchServerStatus
}