Update sdk/js/server/query

Braydon 2024-04-15 12:50:12 -07:00
parent 390e7c0895
commit 4db58ce747

@ -2,14 +2,22 @@
## Example
```ts
import { CachedJavaMinecraftServer, CachedBedrockMinecraftServer } from "restfulmc-lib";
import { getMinecraftServer } from "restfulmc-lib";
import {
ServerPlatform,
getMinecraftServer,
type CachedBedrockMinecraftServer,
type CachedJavaMinecraftServer,
type RestfulMCAPIError,
} from "restfulmc-lib";
try {
const server: CachedJavaMinecraftServer | CachedBedrockMinecraftServer = await getMinecraftServer(Platform.JAVA / Platform.BEDROCK, "hypixel.net");
console.log(`Pinged ${server.ip}:${server.port}, there are ${server.players.online}/${server.players.max} players online`);
const server: CachedJavaMinecraftServer | CachedBedrockMinecraftServer =
await getMinecraftServer(ServerPlatform.JAVA, "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) {
if ((err as RestfulMCAPIError).code == 404) {
console.error("Server couldn't be found, is it offline?");
}
}