exaroton 1.6.1 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -4
- package/package.json +1 -1
- package/src/Client.js +1 -1
- package/src/Server/Server.js +42 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## About
|
|
4
4
|
The exaroton API allows automated access to some basic functionalities of your game servers, such as starting or stopping
|
|
5
|
-
the server. You can read the API documentation here: https://
|
|
5
|
+
the server. You can read the API documentation here: https://developers.exaroton.com
|
|
6
6
|
|
|
7
7
|
This is the official Node.js implementation of this API.
|
|
8
8
|
|
|
@@ -32,7 +32,7 @@ let account = await client.getAccount();
|
|
|
32
32
|
console.log("My account is " + account.name + " and I have " + account.credits + " credits.");
|
|
33
33
|
````
|
|
34
34
|
|
|
35
|
-
The account object contains the fields and information as listed in the [documentation](https://
|
|
35
|
+
The account object contains the fields and information as listed in the [documentation](https://developers.exaroton.com/#account-get).
|
|
36
36
|
|
|
37
37
|
#### List servers
|
|
38
38
|
```js
|
|
@@ -43,7 +43,7 @@ for(let server of servers) {
|
|
|
43
43
|
}
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
Each server object contains the fields and information as listed in the [documentation](https://
|
|
46
|
+
Each server object contains the fields and information as listed in the [documentation](https://developers.exaroton.com/#servers-get).
|
|
47
47
|
|
|
48
48
|
#### Create a server object by ID
|
|
49
49
|
```js
|
|
@@ -68,7 +68,7 @@ if (server.hasStatus(server.STATUS.ONLINE)) {
|
|
|
68
68
|
console.log("Server is offline.");
|
|
69
69
|
}
|
|
70
70
|
```
|
|
71
|
-
The server status is an `integer` as described in the [documentation](https://
|
|
71
|
+
The server status is an `integer` as described in the [documentation](https://developers.exaroton.com/#header-server-status). You can use
|
|
72
72
|
the [ServerStatus](./src/Server/ServerStatus.js) object, which you can require on its own `const {ServerStatus} = require('exaroton')` or via the
|
|
73
73
|
shorthand `server.STATUS` property.
|
|
74
74
|
|
|
@@ -136,6 +136,25 @@ try {
|
|
|
136
136
|
```
|
|
137
137
|
The RAM is set in full GiB and has to be between 2 and 16.
|
|
138
138
|
|
|
139
|
+
#### Get the server MOTD
|
|
140
|
+
```js
|
|
141
|
+
try {
|
|
142
|
+
let motd = await server.getMOTD();
|
|
143
|
+
console.log(motd);
|
|
144
|
+
} catch (e) {
|
|
145
|
+
console.error(e.message);
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
#### Set the server MOTD
|
|
150
|
+
```js
|
|
151
|
+
try {
|
|
152
|
+
await server.setMOTD("Hello world!");
|
|
153
|
+
} catch (e) {
|
|
154
|
+
console.error(e.message);
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
139
158
|
#### Player lists
|
|
140
159
|
A player list is a list of players such as the whitelist, ops or bans.
|
|
141
160
|
Player list entries are usually usernames, but might be something else, e.g. IPs in the banned-ips list.
|
package/package.json
CHANGED
package/src/Client.js
CHANGED
package/src/Server/Server.js
CHANGED
|
@@ -236,6 +236,24 @@ class Server extends EventEmitter {
|
|
|
236
236
|
return this.setOption("ram", ram);
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
+
/**
|
|
240
|
+
* Get the server MOTD
|
|
241
|
+
*
|
|
242
|
+
* @returns {Promise<string>}
|
|
243
|
+
*/
|
|
244
|
+
getMOTD() {
|
|
245
|
+
return this.getOption("motd");
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Set the server MOTD
|
|
250
|
+
*
|
|
251
|
+
* @param {string} motd
|
|
252
|
+
* @returns {Promise<Response>}
|
|
253
|
+
*/
|
|
254
|
+
setMOTD(motd) {
|
|
255
|
+
return this.setOption("motd", motd);
|
|
256
|
+
}
|
|
239
257
|
|
|
240
258
|
/**
|
|
241
259
|
* Get a server option
|
|
@@ -326,7 +344,7 @@ class Server extends EventEmitter {
|
|
|
326
344
|
* Subscribe to one or multiple streams
|
|
327
345
|
*
|
|
328
346
|
* @return {boolean}
|
|
329
|
-
* @param {string[]|string} streams
|
|
347
|
+
* @param {string[]|string} [streams]
|
|
330
348
|
*/
|
|
331
349
|
subscribe(streams) {
|
|
332
350
|
let websocketClient = this.getWebsocketClient();
|
|
@@ -354,7 +372,7 @@ class Server extends EventEmitter {
|
|
|
354
372
|
/**
|
|
355
373
|
* Unsubscribe from one, multiple or all streams
|
|
356
374
|
*
|
|
357
|
-
* @param {string[]|string} streams
|
|
375
|
+
* @param {string[]|string} [streams]
|
|
358
376
|
*/
|
|
359
377
|
unsubscribe(streams) {
|
|
360
378
|
let websocketClient = this.getWebsocketClient();
|
|
@@ -403,6 +421,28 @@ class Server extends EventEmitter {
|
|
|
403
421
|
}
|
|
404
422
|
return this;
|
|
405
423
|
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Only return intended public fields for JSON serialization
|
|
427
|
+
*
|
|
428
|
+
* Otherwise, fields inherited from EventEmitter would be serialized as well
|
|
429
|
+
*
|
|
430
|
+
* @returns {{}}
|
|
431
|
+
*/
|
|
432
|
+
toJSON() {
|
|
433
|
+
return {
|
|
434
|
+
id: this.id,
|
|
435
|
+
name: this.name,
|
|
436
|
+
address: this.address,
|
|
437
|
+
motd: this.motd,
|
|
438
|
+
status: this.status,
|
|
439
|
+
host: this.host,
|
|
440
|
+
port: this.port,
|
|
441
|
+
shared: this.shared,
|
|
442
|
+
software: this.software,
|
|
443
|
+
players: this.players
|
|
444
|
+
}
|
|
445
|
+
}
|
|
406
446
|
}
|
|
407
447
|
|
|
408
448
|
module.exports = Server;
|