Skip to content

Commit 7cb9449

Browse files
authored
Merge pull request #8 from KurtThiemann/extend-time
Add method to extend server stop timer
2 parents 587d83b + 34a5616 commit 7cb9449

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "exaroton",
3-
"version": "1.11.3",
3+
"version": "1.12.0",
44
"description": "exaroton API client",
55
"homepage": "https://exaroton.com",
66
"main": "index.js",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const ServerRequest = require('./ServerRequest');
2+
3+
class ExtendServerStopTimeRequest extends ServerRequest {
4+
endpoint = "servers/{id}/extend-time";
5+
method = "POST";
6+
7+
/**
8+
* ExecuteServerCommandRequest constructor
9+
*
10+
* @param {string} id
11+
* @param {number} time
12+
*/
13+
constructor(id, time) {
14+
super(id);
15+
16+
this.data = {time: time};
17+
}
18+
}
19+
20+
module.exports = ExtendServerStopTimeRequest;

src/Server/Server.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const ShareServerLogsRequest = require('../Request/Server/ShareServerLogsRequest
1616
const GetServerOptionRequest = require('../Request/Server/GetServerOptionRequest');
1717
const SetServerOptionRequest = require('../Request/Server/SetServerOptionRequest');
1818
const GetPlayerListsRequest = require('../Request/Server/PlayerLists/GetPlayerListsRequest');
19+
const ExtendServerStopTimeRequest = require("../Request/Server/ExtendServerStopTimeRequest.js");
1920

2021
class Server extends EventEmitter {
2122
/**
@@ -195,6 +196,17 @@ class Server extends EventEmitter {
195196
return this.#client.request(new ExecuteServerCommandRequest(this.id, command));
196197
}
197198

199+
/**
200+
* Extend the time until the server automatically stops
201+
*
202+
* @param {number} time
203+
* @return {Promise<Response>}
204+
* @throws {RequestError}
205+
*/
206+
async extendStopTime(time) {
207+
return this.#client.request(new ExtendServerStopTimeRequest(this.id, time));
208+
}
209+
198210
/**
199211
* Get the content of the server logs
200212
*
@@ -460,4 +472,4 @@ class Server extends EventEmitter {
460472
}
461473
}
462474

463-
module.exports = Server;
475+
module.exports = Server;

0 commit comments

Comments
 (0)