fix: readme example and add more options to the simple example

This commit is contained in:
CosminPerRam 2024-01-22 23:17:07 +02:00
parent e89cb125b2
commit 16e9454beb
2 changed files with 6 additions and 4 deletions

View File

@ -18,15 +18,15 @@ See the [GAMES_LIST.md](GAMES_LIST.md) file for the currently supported titles,
## Usage from Node.js
Install using your favorite package manager: `npm install gamedig`, then use!
```js
import GameDig from 'gamedig';
import { GameDig } from 'gamedig';
GameDig.query({
type: 'minecraft',
host: 'mc.example.com'
host: 'mc.hypixel.net'
}).then((state) => {
console.log(state);
}).catch((error) => {
console.log("Server is offline");
console.log(`Server is offline, error: ${error}`);
});
```
Confused on how this works, or you want to see more? Checkout the [examples](/examples) folder!

View File

@ -3,7 +3,9 @@ import { GameDig } from '../lib/index.js'
GameDig.query({
type: 'minecraft',
host: 'mc.hypixel.net'
host: 'mc.hypixel.net',
port: 25565, // lets us explicitly specify the query port of this server
givenPortOnly: true // the library will attempt multiple ports in order to ensure success, to avoid this pass this option
}).then((state) => {
console.log(state)
}).catch((error) => {