mirror of
https://github.com/gamedig/node-gamedig.git
synced 2024-09-21 01:41:31 +02:00
fix: readme example and add more options to the simple example
This commit is contained in:
parent
e89cb125b2
commit
16e9454beb
@ -18,15 +18,15 @@ See the [GAMES_LIST.md](GAMES_LIST.md) file for the currently supported titles,
|
|||||||
## Usage from Node.js
|
## Usage from Node.js
|
||||||
Install using your favorite package manager: `npm install gamedig`, then use!
|
Install using your favorite package manager: `npm install gamedig`, then use!
|
||||||
```js
|
```js
|
||||||
import GameDig from 'gamedig';
|
import { GameDig } from 'gamedig';
|
||||||
|
|
||||||
GameDig.query({
|
GameDig.query({
|
||||||
type: 'minecraft',
|
type: 'minecraft',
|
||||||
host: 'mc.example.com'
|
host: 'mc.hypixel.net'
|
||||||
}).then((state) => {
|
}).then((state) => {
|
||||||
console.log(state);
|
console.log(state);
|
||||||
}).catch((error) => {
|
}).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!
|
Confused on how this works, or you want to see more? Checkout the [examples](/examples) folder!
|
||||||
|
@ -3,7 +3,9 @@ import { GameDig } from '../lib/index.js'
|
|||||||
|
|
||||||
GameDig.query({
|
GameDig.query({
|
||||||
type: 'minecraft',
|
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) => {
|
}).then((state) => {
|
||||||
console.log(state)
|
console.log(state)
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user