Add sdk/js/server/query

Braydon 2024-04-14 15:13:19 -07:00
parent 95e9cd1eda
commit 7ca3a0749b

@ -0,0 +1,16 @@
# Query Server
## Example
```ts
import { CachedJavaMinecraftServer, CachedBedrockMinecraftServer } from "restfulmc-lib";
import { getMinecraftServer } from "restfulmc-lib";
try {
const server: CachedJavaMinecraftServer | CachedBedrockMinecraftServer = await getMinecraftServer("java / bedrock", "hypixel.net");
console.log(`Pinged ${server.ip}:${server.port}, there are ${server.players.online}/${server.players.max} players online`);
} catch (err) {
if ((err as ErrorResponse).code == 404) {
console.error("Server couldn't be found, is it offline?");
}
}
```