Skip to content

Commit

Permalink
export mojang-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen3H committed Sep 16, 2023
1 parent 6633216 commit d0f9f49
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import { Map } from './Map.js'
import * as endpoint from './utils/endpoint.js'
import * as Errors from "./utils/errors.js"

async function getServerData() {
const serverData = await MCAPI.servers.get("play.earthmc.net")
async function fetchServer(name = "play.earthmc.net") {
const server = await MCAPI.servers.get(name)

return {
serverOnline: !!serverData,
online: serverData?.players?.online ?? 0,
max: serverData?.players?.max ?? 0
max: server?.players?.max ?? 0,
online: server?.players?.online ?? 0,
serverOnline: !!server
}
}

async function getServerInfo() {
try {
const serverData = await getServerData(),
const serverData = await fetchServer(),
novaData = await endpoint.playerData("nova"),
auroraData = await endpoint.playerData("aurora")

Expand All @@ -42,8 +42,10 @@ const Nova = new Map('nova')
export { formatString } from './utils/functions.js'
export {
Errors,
MCAPI as MojangLib,
OfficialAPI,
endpoint,
endpoint,
fetchServer,
getServerInfo,
Aurora, Nova,
Map
Expand Down

0 comments on commit d0f9f49

Please sign in to comment.