From 7ca3a0749b743b494faf5af526690dda99fb0d14 Mon Sep 17 00:00:00 2001 From: Braydon Date: Sun, 14 Apr 2024 15:13:19 -0700 Subject: [PATCH] Add sdk/js/server/query --- sdk%2Fjs%2Fserver%2Fquery.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 sdk%2Fjs%2Fserver%2Fquery.md diff --git a/sdk%2Fjs%2Fserver%2Fquery.md b/sdk%2Fjs%2Fserver%2Fquery.md new file mode 100644 index 0000000..1ca11a0 --- /dev/null +++ b/sdk%2Fjs%2Fserver%2Fquery.md @@ -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?"); + } +} +``` \ No newline at end of file