UNPKG

@shorkiedev/mc-status

Version:

A simple ESM package that can check multiple minecraft server status.

39 lines 1.4 kB
/** * MAIN FILE ENTRY (index.js) - Sh4rk7 (A lil cutie bear) */ import { getJavaServer } from "./mc/minecraftJava.js"; import { getBedrockServer } from "./mc/minecraftBedrock.js"; export async function pingServers(servers) { const results = await Promise.allSettled(servers.map(async (srv) => { if (srv.type === "java") { const port = srv.port ?? 25565; const status = await getJavaServer(srv.host, port, srv.timeout ?? 15000); return { name: srv.name, type: "java", ...status }; } else { const options = { port: srv.port ?? 19132, timeout: srv.timeout ?? 15000 }; const status = await getBedrockServer(srv.host, options); return { name: srv.name, type: "bedrock", ...status }; } })); return results.map((result, idx) => { if (result.status === "fulfilled") { return result.value; } else { const srv = servers[idx]; return { name: srv?.name ?? "unknown", type: (srv?.type ?? "java"), online: false, latency: null, motd: null, playersOnline: null, playersMax: null, version: null, }; } }); } export { getJavaServer, getBedrockServer }; //# sourceMappingURL=index.js.map