Skip to content

Commit ddfbe9d

Browse files
authored
🤖 Merge PR DefinitelyTyped#71831 update exaroton to match version 1.11.3 by @maxiicodes
1 parent 669ab52 commit ddfbe9d

File tree

2 files changed

+42
-23
lines changed

2 files changed

+42
-23
lines changed

types/exaroton/exaroton-tests.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Client } from "exaroton";
1+
import { Client, ServerStatus } from "exaroton";
22

33
const client = new Client("my token");
44

@@ -7,12 +7,12 @@ const startServer = async (name: string) => {
77
const myServer = servers.find(s => s.name === name);
88
if (!myServer) throw Error("Server not found");
99
await myServer.setMOTD("Hello World");
10-
console.log(myServer?.status);
11-
if (myServer?.hasStatus([myServer.STATUS.ONLINE, myServer.STATUS.STARTING])) return;
12-
await myServer?.start();
13-
console.log(`${myServer?.name} has benn started. Running on: ${myServer?.address}`);
14-
console.log(myServer?.status);
15-
console.log(myServer?.players.max);
10+
console.log(myServer.status);
11+
if (myServer.hasStatus([myServer.STATUS.ONLINE, ServerStatus.STARTING])) return;
12+
await myServer.start();
13+
console.log(`${myServer.name} has benn started. Running on: ${myServer.address}`);
14+
console.log(myServer.status);
15+
console.log(myServer.players.max);
1616

1717
const myServerProperties = myServer.getFile("server.properties");
1818
const config = myServerProperties.getConfig();
@@ -50,6 +50,7 @@ const startServer = async (name: string) => {
5050
myServer.subscribe(["stats", "heap"]);
5151
myServer.on("stats:stats", data => console.log(data.memory.usage));
5252
myServer.on("heap:heap", data => console.log(data.usage));
53+
myServer.unsubscribe();
5354
};
5455

5556
startServer("my server");

types/exaroton/index.d.ts

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ declare enum ServerStatus {
1515
LOADING = 6,
1616
CRASHED = 7,
1717
PENDING = 8,
18+
TRANSFERRING = 9,
1819
PREPARING = 10,
1920
}
2021

@@ -23,12 +24,12 @@ declare class Client {
2324
* The protocol type used for request
2425
*
2526
* Can be http, https, ws or wss
26-
* @defaultValue htttps
27+
* @defaultValue https
2728
*/
2829
protocol: string;
2930

3031
/**
31-
* The hostname the client uses to retireve all data
32+
* The hostname the client uses to retrieve all data
3233
*
3334
* @defaultValue api.exaroton.com
3435
*/
@@ -162,7 +163,7 @@ declare class Request {
162163
headers: Record<string, any>;
163164

164165
/**
165-
* Post body data
166+
* POST-body data
166167
*/
167168
data: null | Record<string, any> | string;
168169

@@ -280,15 +281,15 @@ declare class Request {
280281
setData(data: string | Record<string, any>): this;
281282

282283
/**
283-
* Set a file as input file for the request body
284+
* Set a file as an input file for the request body
284285
*
285286
* @param {string} inputPath
286287
* @return {this}
287288
*/
288289
setInputPath(inputPath: string): Request;
289290

290291
/**
291-
* Set a file as output file for the response body
292+
* Set a file as an output file for the response body
292293
*
293294
* @param {string} outputPath
294295
* @return {this}
@@ -340,7 +341,7 @@ declare class Response {
340341

341342
declare class File {
342343
/**
343-
* File path relative to server root
344+
* The file path relative to server root
344345
*/
345346
path: string;
346347

@@ -411,7 +412,7 @@ declare class File {
411412
/**
412413
* Get the data/content of a file
413414
*
414-
* If you want to download the file to a local file use File.download() instead
415+
* If you want to download the file to a local file, use File.download() instead
415416
*
416417
* @return {Promise<string>}
417418
*/
@@ -420,7 +421,7 @@ declare class File {
420421
/**
421422
* Download the data/content of a file to a local file
422423
*
423-
* If you want to use the content of the file directly use File.getContent() instead
424+
* If you want to use the content of the file directly, use File.getContent() instead
424425
*
425426
* @param {string} outputPath
426427
* @return {Promise<Response>}
@@ -438,7 +439,7 @@ declare class File {
438439
/**
439440
* Put the content of a file
440441
*
441-
* If you want to upload a local file use File.upload() instead
442+
* If you want to upload a local file, use File.upload() instead
442443
*
443444
* @param {string} content
444445
* @return {Promise<Response>}
@@ -448,7 +449,7 @@ declare class File {
448449
/**
449450
* Upload a local file
450451
*
451-
* If you want to upload the content of the file directly as a string use File.putContent() instead
452+
* If you want to upload the content of the file directly as a string, use File.putContent() instead
452453
*
453454
* @param {string} inputPath
454455
* @return {Promise<Response>}
@@ -485,7 +486,7 @@ declare class File {
485486
getChildren(): Promise<File[] | null>;
486487

487488
/**
488-
* Get Config object for this file
489+
* Get the Config object for this file
489490
* Only available if the file is a config file
490491
*
491492
* @return {Config}
@@ -572,7 +573,7 @@ declare class Pool {
572573
owner?: string;
573574

574575
/**
575-
* Is pool owner
576+
* Is a pool owner
576577
*/
577578
isOwner?: boolean;
578579

@@ -640,7 +641,7 @@ declare class PoolMember {
640641
credits: number;
641642

642643
/**
643-
* Is pool owner
644+
* Is a pool owner
644645
*/
645646
isOwner: boolean;
646647

@@ -666,12 +667,28 @@ interface Software {
666667
readonly version: string;
667668
}
668669

670+
interface TickData {
671+
averageTickTime: number;
672+
tps: number;
673+
}
674+
675+
interface StatsData {
676+
memory: {
677+
percent: number;
678+
usage: number;
679+
};
680+
}
681+
682+
interface HeapData {
683+
usage: number;
684+
}
685+
669686
export interface StreamTypes {
670687
status: [server: Server];
671688
"console:line": [data: string];
672-
"tick:tick": [data: { averageTickTime: number; tps: number }];
673-
"stats:stats": [data: { memory: { percent: number; usage: number } }];
674-
"heap:heap": [data: { usage: number }];
689+
"tick:tick": [data: TickData];
690+
"stats:stats": [data: StatsData];
691+
"heap:heap": [data: HeapData];
675692
}
676693

677694
declare class Server extends EventEmitter {
@@ -688,6 +705,7 @@ declare class Server extends EventEmitter {
688705
readonly LOADING: 6;
689706
readonly CRASHED: 7;
690707
readonly PENDING: 8;
708+
readonly TRANSFERRING: 9;
691709
readonly PREPARING: 10;
692710
};
693711

0 commit comments

Comments
 (0)