Add sdk/js/server/query
parent
95e9cd1eda
commit
7ca3a0749b
16
sdk%2Fjs%2Fserver%2Fquery.md
Normal file
16
sdk%2Fjs%2Fserver%2Fquery.md
Normal file
@ -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?");
|
||||
}
|
||||
}
|
||||
```
|
Loading…
Reference in New Issue
Block a user