node-gamedig/examples/require.cjs
Guilherme Werner 38ddfd61f3
feat: add support to CommonJS (#519)
* Add support to CommonJS

* Fixes

* Update CHANGELOG.md
2024-01-29 22:55:25 +02:00

13 lines
496 B
JavaScript

const { GameDig } = require('../dist/index.cjs')
// Instead of '../dist/index.cjs' you would have here 'gamedig'.
GameDig.query({
type: 'minecraft',
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) => {
console.log(`Server is offline, error: ${error}`)
})