@erlcjs/core 1.0.0
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 +111 -0
- package/dist/index.d.mts +1218 -0
- package/dist/index.d.ts +1218 -0
- package/dist/index.js +1324 -0
- package/dist/index.mjs +1277 -0
- package/package.json +38 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1218 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for the ERLCApi Client.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
interface ClientOptions {
|
|
8
|
+
/**
|
|
9
|
+
* The ER:LC Server API Key.
|
|
10
|
+
*/
|
|
11
|
+
serverKey: string;
|
|
12
|
+
/**
|
|
13
|
+
* Optional global key for wider API access.
|
|
14
|
+
*/
|
|
15
|
+
globalKey?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Webhook configuration details.
|
|
18
|
+
*/
|
|
19
|
+
webhook?: {
|
|
20
|
+
/**
|
|
21
|
+
* Whether to enable the webhook server.
|
|
22
|
+
*/
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The port to run the webhook server on.
|
|
26
|
+
*/
|
|
27
|
+
port: number;
|
|
28
|
+
/**
|
|
29
|
+
* The URL path for incoming webhooks.
|
|
30
|
+
*/
|
|
31
|
+
path?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Secret key used for authenticating incoming webhooks.
|
|
34
|
+
*/
|
|
35
|
+
secret?: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Whether to poll the ER:LC API endpoints periodically.
|
|
39
|
+
*/
|
|
40
|
+
polling?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Raw data structure representing a player from the ERLC API.
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
interface RawPlayerData {
|
|
47
|
+
/**
|
|
48
|
+
* The player identifier, in the format `Username:UserId`.
|
|
49
|
+
*/
|
|
50
|
+
Player: string;
|
|
51
|
+
/**
|
|
52
|
+
* The permission level of the player in the server.
|
|
53
|
+
*/
|
|
54
|
+
Permission: 'Normal' | 'Server Administrator' | 'Server Owner' | 'Server Moderator';
|
|
55
|
+
/**
|
|
56
|
+
* The team the player is currently on.
|
|
57
|
+
*/
|
|
58
|
+
Team: string;
|
|
59
|
+
/**
|
|
60
|
+
* The player's optional callsign.
|
|
61
|
+
*/
|
|
62
|
+
Callsign: string;
|
|
63
|
+
/**
|
|
64
|
+
* The player's location coordinates and address details.
|
|
65
|
+
*/
|
|
66
|
+
Location: {
|
|
67
|
+
/**
|
|
68
|
+
* The X coordinate of the player in the game.
|
|
69
|
+
*/
|
|
70
|
+
LocationX: number;
|
|
71
|
+
/**
|
|
72
|
+
* The Y coordinate of the player in the game.
|
|
73
|
+
*/
|
|
74
|
+
LocationY: number;
|
|
75
|
+
/**
|
|
76
|
+
* The postal code of the player's location.
|
|
77
|
+
*/
|
|
78
|
+
PostalCode: string;
|
|
79
|
+
/**
|
|
80
|
+
* The street name of the player's location.
|
|
81
|
+
*/
|
|
82
|
+
StreetName: string;
|
|
83
|
+
/**
|
|
84
|
+
* The building number of the player's location.
|
|
85
|
+
*/
|
|
86
|
+
BuildingNumber: string;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* The number of wanted stars the player currently has.
|
|
90
|
+
*/
|
|
91
|
+
WantedStars: number;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Raw data structure representing server staff records.
|
|
95
|
+
* @public
|
|
96
|
+
*/
|
|
97
|
+
interface RawStaffData {
|
|
98
|
+
/**
|
|
99
|
+
* Record of server administrators (UserId to Username).
|
|
100
|
+
*/
|
|
101
|
+
Admins: Record<string, string>;
|
|
102
|
+
/**
|
|
103
|
+
* Record of server moderators (UserId to Username).
|
|
104
|
+
*/
|
|
105
|
+
Mods: Record<string, string>;
|
|
106
|
+
/**
|
|
107
|
+
* Record of server helpers (UserId to Username).
|
|
108
|
+
*/
|
|
109
|
+
Helpers: Record<string, string>;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Raw data structure representing a server join/leave log entry.
|
|
113
|
+
* @public
|
|
114
|
+
*/
|
|
115
|
+
interface RawJoinLog {
|
|
116
|
+
/**
|
|
117
|
+
* True if the player joined, false if they left.
|
|
118
|
+
*/
|
|
119
|
+
Join: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Unix timestamp of when the event occurred.
|
|
122
|
+
*/
|
|
123
|
+
Timestamp: number;
|
|
124
|
+
/**
|
|
125
|
+
* The player identifier, in the format `Username:UserId`.
|
|
126
|
+
*/
|
|
127
|
+
Player: string;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Raw data structure representing a kill log entry.
|
|
131
|
+
* @public
|
|
132
|
+
*/
|
|
133
|
+
interface RawKillLog {
|
|
134
|
+
/**
|
|
135
|
+
* The identifier of the player who was killed (`Username:UserId`).
|
|
136
|
+
*/
|
|
137
|
+
Killed: string;
|
|
138
|
+
/**
|
|
139
|
+
* Unix timestamp of when the kill occurred.
|
|
140
|
+
*/
|
|
141
|
+
Timestamp: number;
|
|
142
|
+
/**
|
|
143
|
+
* The identifier of the player who did the killing (`Username:UserId`).
|
|
144
|
+
*/
|
|
145
|
+
Killer: string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Raw data structure representing a executed command log entry.
|
|
149
|
+
* @public
|
|
150
|
+
*/
|
|
151
|
+
interface RawCommandLog {
|
|
152
|
+
/**
|
|
153
|
+
* The identifier of the player who ran the command (`Username:UserId`).
|
|
154
|
+
*/
|
|
155
|
+
Player: string;
|
|
156
|
+
/**
|
|
157
|
+
* Unix timestamp of when the command was run.
|
|
158
|
+
*/
|
|
159
|
+
Timestamp: number;
|
|
160
|
+
/**
|
|
161
|
+
* The command string that was executed.
|
|
162
|
+
*/
|
|
163
|
+
Command: string;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Raw data structure representing a moderator call log.
|
|
167
|
+
* @public
|
|
168
|
+
*/
|
|
169
|
+
interface RawModCall {
|
|
170
|
+
/**
|
|
171
|
+
* The identifier of the caller (`Username:UserId`).
|
|
172
|
+
*/
|
|
173
|
+
Caller: string;
|
|
174
|
+
/**
|
|
175
|
+
* The identifier of the moderator who responded, if any (`Username:UserId`).
|
|
176
|
+
*/
|
|
177
|
+
Moderator?: string;
|
|
178
|
+
/**
|
|
179
|
+
* Unix timestamp of the moderator call.
|
|
180
|
+
*/
|
|
181
|
+
Timestamp: number;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Raw data structure representing an emergency call.
|
|
185
|
+
* @public
|
|
186
|
+
*/
|
|
187
|
+
interface RawEmergencyCall {
|
|
188
|
+
/**
|
|
189
|
+
* The team name associated with the emergency call.
|
|
190
|
+
*/
|
|
191
|
+
Team: string;
|
|
192
|
+
/**
|
|
193
|
+
* The UserId of the player who made the call.
|
|
194
|
+
*/
|
|
195
|
+
Caller: number;
|
|
196
|
+
/**
|
|
197
|
+
* List of UserIds of responders currently assigned to this call.
|
|
198
|
+
*/
|
|
199
|
+
Players: number[];
|
|
200
|
+
/**
|
|
201
|
+
* Position coordinates [x, y] of the emergency call.
|
|
202
|
+
*/
|
|
203
|
+
Position: number[];
|
|
204
|
+
/**
|
|
205
|
+
* Unix timestamp of when the call was created.
|
|
206
|
+
*/
|
|
207
|
+
StartedAt: number;
|
|
208
|
+
/**
|
|
209
|
+
* The unique call number.
|
|
210
|
+
*/
|
|
211
|
+
CallNumber: number;
|
|
212
|
+
/**
|
|
213
|
+
* The description text of the call.
|
|
214
|
+
*/
|
|
215
|
+
Description: string;
|
|
216
|
+
/**
|
|
217
|
+
* Descriptors of the position where the call was made.
|
|
218
|
+
*/
|
|
219
|
+
PositionDescriptor: string;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Raw data structure representing a vehicle.
|
|
223
|
+
* @public
|
|
224
|
+
*/
|
|
225
|
+
interface RawVehicle {
|
|
226
|
+
/**
|
|
227
|
+
* The name/model of the vehicle.
|
|
228
|
+
*/
|
|
229
|
+
Name: string;
|
|
230
|
+
/**
|
|
231
|
+
* The username of the vehicle owner.
|
|
232
|
+
*/
|
|
233
|
+
Owner: string;
|
|
234
|
+
/**
|
|
235
|
+
* The license plate of the vehicle.
|
|
236
|
+
*/
|
|
237
|
+
Plate: string;
|
|
238
|
+
/**
|
|
239
|
+
* The custom texture path or name of the vehicle.
|
|
240
|
+
*/
|
|
241
|
+
Texture?: string;
|
|
242
|
+
/**
|
|
243
|
+
* Hexadecimal color code of the vehicle.
|
|
244
|
+
*/
|
|
245
|
+
ColorHex: string;
|
|
246
|
+
/**
|
|
247
|
+
* The color name of the vehicle.
|
|
248
|
+
*/
|
|
249
|
+
ColorName: string;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Raw data structure representing the full server information payload from ER:LC.
|
|
253
|
+
* @public
|
|
254
|
+
*/
|
|
255
|
+
interface RawServerData {
|
|
256
|
+
/**
|
|
257
|
+
* The server name.
|
|
258
|
+
*/
|
|
259
|
+
Name: string;
|
|
260
|
+
/**
|
|
261
|
+
* The UserId of the server owner.
|
|
262
|
+
*/
|
|
263
|
+
OwnerId: number;
|
|
264
|
+
/**
|
|
265
|
+
* List of UserIds of server co-owners.
|
|
266
|
+
*/
|
|
267
|
+
CoOwnerIds: number[];
|
|
268
|
+
/**
|
|
269
|
+
* Number of players currently in the server.
|
|
270
|
+
*/
|
|
271
|
+
CurrentPlayers: number;
|
|
272
|
+
/**
|
|
273
|
+
* Maximum allowed players in the server.
|
|
274
|
+
*/
|
|
275
|
+
MaxPlayers: number;
|
|
276
|
+
/**
|
|
277
|
+
* The join key of the server.
|
|
278
|
+
*/
|
|
279
|
+
JoinKey: string;
|
|
280
|
+
/**
|
|
281
|
+
* Verification level requirement for joining.
|
|
282
|
+
*/
|
|
283
|
+
AccVerifiedReq: 'Disabled' | 'Email' | 'Phone/ID';
|
|
284
|
+
/**
|
|
285
|
+
* Whether team balance is enabled.
|
|
286
|
+
*/
|
|
287
|
+
TeamBalance: boolean;
|
|
288
|
+
/**
|
|
289
|
+
* List of active players.
|
|
290
|
+
*/
|
|
291
|
+
Players?: RawPlayerData[];
|
|
292
|
+
/**
|
|
293
|
+
* Server staff lists.
|
|
294
|
+
*/
|
|
295
|
+
Staff?: RawStaffData[];
|
|
296
|
+
/**
|
|
297
|
+
* Server join/leave logs.
|
|
298
|
+
*/
|
|
299
|
+
JoinLogs?: RawJoinLog[];
|
|
300
|
+
/**
|
|
301
|
+
* UserIds currently in the join queue.
|
|
302
|
+
*/
|
|
303
|
+
Queue?: number[];
|
|
304
|
+
/**
|
|
305
|
+
* Server kill logs.
|
|
306
|
+
*/
|
|
307
|
+
KillLogs?: RawKillLog[];
|
|
308
|
+
/**
|
|
309
|
+
* Server command logs.
|
|
310
|
+
*/
|
|
311
|
+
CommandLogs?: RawCommandLog[];
|
|
312
|
+
/**
|
|
313
|
+
* Active moderator calls.
|
|
314
|
+
*/
|
|
315
|
+
ModCalls?: RawModCall[];
|
|
316
|
+
/**
|
|
317
|
+
* Active emergency calls.
|
|
318
|
+
*/
|
|
319
|
+
EmergencyCalls?: RawEmergencyCall[];
|
|
320
|
+
/**
|
|
321
|
+
* Active vehicles spawned.
|
|
322
|
+
*/
|
|
323
|
+
Vehicles?: RawVehicle[];
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Handles communication with the ER:LC HTTP API, managing rate limits and request queuing.
|
|
328
|
+
* @public
|
|
329
|
+
*/
|
|
330
|
+
declare class RestManager {
|
|
331
|
+
private options;
|
|
332
|
+
private queue;
|
|
333
|
+
private processing;
|
|
334
|
+
private rateLimitReset;
|
|
335
|
+
private baseUrl;
|
|
336
|
+
/**
|
|
337
|
+
* Creates an instance of RestManager.
|
|
338
|
+
* @param options - The ClientOptions configuration.
|
|
339
|
+
*/
|
|
340
|
+
constructor(options: ClientOptions);
|
|
341
|
+
/**
|
|
342
|
+
* Enqueues and sends an HTTP request to the ER:LC API.
|
|
343
|
+
* @param method - The HTTP method to use ('GET' or 'POST').
|
|
344
|
+
* @param endpoint - The API endpoint path.
|
|
345
|
+
* @param body - The optional request body payload.
|
|
346
|
+
* @returns A promise resolving to the API response data.
|
|
347
|
+
* @throws {@link InvalidServerKeyError} if the server API key is invalid (403).
|
|
348
|
+
* @throws Error - for other HTTP error codes.
|
|
349
|
+
*/
|
|
350
|
+
request(method: 'GET' | 'POST', endpoint: string, body?: any): Promise<any>;
|
|
351
|
+
/**
|
|
352
|
+
* Processes the request queue sequentially.
|
|
353
|
+
*/
|
|
354
|
+
private processQueue;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Represents the base class for all ER:LC structures.
|
|
359
|
+
* @public
|
|
360
|
+
*/
|
|
361
|
+
declare class Base {
|
|
362
|
+
readonly client: Client;
|
|
363
|
+
/**
|
|
364
|
+
* Creates an instance of the Base class.
|
|
365
|
+
* @param client - The ERLCApi client instance.
|
|
366
|
+
*/
|
|
367
|
+
constructor(client: Client);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Represents the ER:LC game server and its current configuration/state.
|
|
372
|
+
* @public
|
|
373
|
+
*/
|
|
374
|
+
declare class Server extends Base {
|
|
375
|
+
/**
|
|
376
|
+
* The name of the server.
|
|
377
|
+
*/
|
|
378
|
+
name: string;
|
|
379
|
+
/**
|
|
380
|
+
* The UserId of the server owner.
|
|
381
|
+
*/
|
|
382
|
+
ownerId: number;
|
|
383
|
+
/**
|
|
384
|
+
* Array of UserIds of server co-owners.
|
|
385
|
+
*/
|
|
386
|
+
coOwnerIds: number[];
|
|
387
|
+
/**
|
|
388
|
+
* The current number of players connected to the server.
|
|
389
|
+
*/
|
|
390
|
+
currentPlayers: number;
|
|
391
|
+
/**
|
|
392
|
+
* The maximum number of players allowed in the server.
|
|
393
|
+
*/
|
|
394
|
+
maxPlayers: number;
|
|
395
|
+
/**
|
|
396
|
+
* The join key of the server.
|
|
397
|
+
*/
|
|
398
|
+
joinKey: string;
|
|
399
|
+
/**
|
|
400
|
+
* Account verification requirements for joining.
|
|
401
|
+
*/
|
|
402
|
+
accVerifiedReq: 'Disabled' | 'Email' | 'Phone/ID';
|
|
403
|
+
/**
|
|
404
|
+
* Whether team balance enforcement is enabled.
|
|
405
|
+
*/
|
|
406
|
+
teamBalance: boolean;
|
|
407
|
+
/**
|
|
408
|
+
* The queue of players waiting to join the server.
|
|
409
|
+
*/
|
|
410
|
+
queue: number[];
|
|
411
|
+
/**
|
|
412
|
+
* Creates an instance of Server.
|
|
413
|
+
* @param client - The ERLCApi client.
|
|
414
|
+
* @param data - The raw server data to initialize.
|
|
415
|
+
*/
|
|
416
|
+
constructor(client: Client, data: RawServerData);
|
|
417
|
+
/**
|
|
418
|
+
* Patches the Server instance with new raw data.
|
|
419
|
+
* @param data - The new raw server data.
|
|
420
|
+
* @returns This server instance.
|
|
421
|
+
*/
|
|
422
|
+
_patch(data: RawServerData): this;
|
|
423
|
+
/**
|
|
424
|
+
* Compares the current server data with another raw data payload to check if it's identical.
|
|
425
|
+
* @param data - The raw server data to compare against.
|
|
426
|
+
* @returns True if the properties are identical, false otherwise.
|
|
427
|
+
*/
|
|
428
|
+
compare(data: RawServerData): boolean;
|
|
429
|
+
/**
|
|
430
|
+
* Converts this Server instance back to its raw JSON structure.
|
|
431
|
+
* @returns The raw server data.
|
|
432
|
+
*/
|
|
433
|
+
toJSON(): RawServerData;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Manager responsible for fetching and caching the ER:LC Server details.
|
|
438
|
+
* @public
|
|
439
|
+
*/
|
|
440
|
+
declare class ServerManager {
|
|
441
|
+
private readonly client;
|
|
442
|
+
/**
|
|
443
|
+
* Cached Server structure instance, if fetched.
|
|
444
|
+
*/
|
|
445
|
+
cache?: Server;
|
|
446
|
+
/**
|
|
447
|
+
* Creates an instance of ServerManager.
|
|
448
|
+
* @param client - The ERLCApi client.
|
|
449
|
+
*/
|
|
450
|
+
constructor(client: Client);
|
|
451
|
+
/**
|
|
452
|
+
* Fetches current server information from the API.
|
|
453
|
+
* Patches the cache and emits event updates if there are changes.
|
|
454
|
+
* @returns A promise resolving to the raw server data from the API.
|
|
455
|
+
*/
|
|
456
|
+
fetch(): Promise<RawServerData>;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Represents a player in the ER:LC server.
|
|
461
|
+
* @public
|
|
462
|
+
*/
|
|
463
|
+
declare class Player extends Base {
|
|
464
|
+
/**
|
|
465
|
+
* The unique UserId of the player.
|
|
466
|
+
*/
|
|
467
|
+
id: number;
|
|
468
|
+
/**
|
|
469
|
+
* The Roblox username of the player.
|
|
470
|
+
*/
|
|
471
|
+
username: string;
|
|
472
|
+
/**
|
|
473
|
+
* The in-game team name the player is currently on.
|
|
474
|
+
*/
|
|
475
|
+
team: string;
|
|
476
|
+
/**
|
|
477
|
+
* The player's callsign, if assigned.
|
|
478
|
+
*/
|
|
479
|
+
callsign?: string;
|
|
480
|
+
/**
|
|
481
|
+
* The current location coordinates and address of the player.
|
|
482
|
+
*/
|
|
483
|
+
location: {
|
|
484
|
+
/** The X coordinate in-game. */
|
|
485
|
+
x: number;
|
|
486
|
+
/** The Y coordinate in-game. */
|
|
487
|
+
y: number;
|
|
488
|
+
/** The postal code of the street. */
|
|
489
|
+
postalCode: string;
|
|
490
|
+
/** The name of the street. */
|
|
491
|
+
streetName: string;
|
|
492
|
+
/** The building number. */
|
|
493
|
+
buildingNumber: string;
|
|
494
|
+
};
|
|
495
|
+
/**
|
|
496
|
+
* The player's server permission role.
|
|
497
|
+
*/
|
|
498
|
+
permission: 'Normal' | 'Server Administrator' | 'Server Owner' | 'Server Moderator';
|
|
499
|
+
/**
|
|
500
|
+
* The player's current wanted star level.
|
|
501
|
+
*/
|
|
502
|
+
wantedLevel: number;
|
|
503
|
+
/**
|
|
504
|
+
* Creates an instance of Player.
|
|
505
|
+
* @param client - The ERLCApi client.
|
|
506
|
+
* @param data - The raw player data to initialize.
|
|
507
|
+
*/
|
|
508
|
+
constructor(client: Client, data: RawPlayerData);
|
|
509
|
+
/**
|
|
510
|
+
* Patches/updates the player structure with new raw data.
|
|
511
|
+
* @param data - The new raw player data.
|
|
512
|
+
* @returns This player instance.
|
|
513
|
+
*/
|
|
514
|
+
_patch(data: RawPlayerData): this;
|
|
515
|
+
/**
|
|
516
|
+
* Kicks the player from the game server.
|
|
517
|
+
* @param reason - The reason for kicking the player. Defaults to "Kicked by API".
|
|
518
|
+
* @returns A promise that resolves when the kick command is sent.
|
|
519
|
+
*/
|
|
520
|
+
kick(reason?: string): Promise<void>;
|
|
521
|
+
/**
|
|
522
|
+
* Bans the player from the game server.
|
|
523
|
+
* @param reason - The reason for banning the player. Defaults to "Banned by API".
|
|
524
|
+
* @returns A promise that resolves when the ban command is sent.
|
|
525
|
+
*/
|
|
526
|
+
ban(reason?: string): Promise<void>;
|
|
527
|
+
/**
|
|
528
|
+
* Jails the player in the game server.
|
|
529
|
+
* @returns A promise that resolves when the jail command is sent.
|
|
530
|
+
*/
|
|
531
|
+
jail(): Promise<void>;
|
|
532
|
+
/**
|
|
533
|
+
* Heals the player in the game server.
|
|
534
|
+
* @returns A promise that resolves when the heal command is sent.
|
|
535
|
+
*/
|
|
536
|
+
heal(): Promise<void>;
|
|
537
|
+
/**
|
|
538
|
+
* Kills the player in-game.
|
|
539
|
+
* @returns A promise that resolves when the kill command is sent.
|
|
540
|
+
*/
|
|
541
|
+
kill(): Promise<void>;
|
|
542
|
+
/**
|
|
543
|
+
* Helpers the player in-game.
|
|
544
|
+
* @returns A promise that resolves when the helper command is sent.
|
|
545
|
+
*/
|
|
546
|
+
helper(): Promise<void>;
|
|
547
|
+
/**
|
|
548
|
+
* Unhelpers the player in-game.
|
|
549
|
+
* @returns A promise that resolves when the unhelper command is sent.
|
|
550
|
+
*/
|
|
551
|
+
unhelper(): Promise<void>;
|
|
552
|
+
/**
|
|
553
|
+
* Mods the player in-game.
|
|
554
|
+
* @returns A promise that resolves when the mod command is sent.
|
|
555
|
+
*/
|
|
556
|
+
mod(): Promise<void>;
|
|
557
|
+
/**
|
|
558
|
+
* Unmods the player in-game.
|
|
559
|
+
* @returns A promise that resolves when the unmod command is sent.
|
|
560
|
+
*/
|
|
561
|
+
unmod(): Promise<void>;
|
|
562
|
+
/**
|
|
563
|
+
* Admins the player in-game.
|
|
564
|
+
* @returns A promise that resolves when the admin command is sent.
|
|
565
|
+
*/
|
|
566
|
+
admin(): Promise<void>;
|
|
567
|
+
/**
|
|
568
|
+
* Unadmins the player in-game.
|
|
569
|
+
* @returns A promise that resolves when the unadmin command is sent.
|
|
570
|
+
*/
|
|
571
|
+
unadmin(): Promise<void>;
|
|
572
|
+
/**
|
|
573
|
+
* Teleports the player to another player.
|
|
574
|
+
* @param player - The player to teleport the player to.
|
|
575
|
+
* @returns A promise that resolves when the teleport command is sent.
|
|
576
|
+
*/
|
|
577
|
+
tp(player: Player | number): Promise<void>;
|
|
578
|
+
/**
|
|
579
|
+
* Sends a private message to the player.
|
|
580
|
+
* @param text - The message body.
|
|
581
|
+
* @returns A promise that resolves when the message command is sent.
|
|
582
|
+
*/
|
|
583
|
+
message(text: string): Promise<void>;
|
|
584
|
+
/**
|
|
585
|
+
* Sends a private message to the player.
|
|
586
|
+
* @param text - The message body.
|
|
587
|
+
* @returns A promise that resolves when the message command is sent.
|
|
588
|
+
*/
|
|
589
|
+
pm(text: string): Promise<void>;
|
|
590
|
+
/**
|
|
591
|
+
* Converts this Player instance back into raw data structure.
|
|
592
|
+
* @returns The raw player data.
|
|
593
|
+
*/
|
|
594
|
+
toJSON(): RawPlayerData;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Manager responsible for fetching, caching, and updating Player structures.
|
|
599
|
+
* @public
|
|
600
|
+
*/
|
|
601
|
+
declare class PlayerManager {
|
|
602
|
+
private readonly client;
|
|
603
|
+
/**
|
|
604
|
+
* Map cache of online Players, keyed by their UserId.
|
|
605
|
+
*/
|
|
606
|
+
cache: Map<number, Player>;
|
|
607
|
+
private nameToId;
|
|
608
|
+
/**
|
|
609
|
+
* Creates an instance of PlayerManager.
|
|
610
|
+
* @param client - The ERLCApi client.
|
|
611
|
+
*/
|
|
612
|
+
constructor(client: Client);
|
|
613
|
+
/**
|
|
614
|
+
* Fetches all active players currently in the game server.
|
|
615
|
+
* Updates the player cache.
|
|
616
|
+
* @returns A promise resolving to a Map of active Players.
|
|
617
|
+
*/
|
|
618
|
+
fetchAll(): Promise<Map<number, Player>>;
|
|
619
|
+
/**
|
|
620
|
+
* Re-synchronizes the cache with the raw player list from the API.
|
|
621
|
+
* Emits playerJoin, playerLeave, and playerUpdate events.
|
|
622
|
+
* @param rawPlayers - Raw player list payload.
|
|
623
|
+
* @returns The updated Player cache Map.
|
|
624
|
+
*/
|
|
625
|
+
updateCache(rawPlayers: RawPlayerData[]): Map<number, Player>;
|
|
626
|
+
/**
|
|
627
|
+
* Retrieves a player's UserId from their Roblox username.
|
|
628
|
+
* Attempts to resolve from cache first, otherwise triggers a fresh fetch.
|
|
629
|
+
* @param name - The Roblox username.
|
|
630
|
+
* @returns The UserId if resolved, otherwise undefined.
|
|
631
|
+
*/
|
|
632
|
+
getIdFromName(name: string): number | undefined;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Manager responsible for executing custom console commands in the ER:LC server.
|
|
637
|
+
* @public
|
|
638
|
+
*/
|
|
639
|
+
declare class CommandManager {
|
|
640
|
+
private readonly client;
|
|
641
|
+
/**
|
|
642
|
+
* Creates an instance of CommandManager.
|
|
643
|
+
* @param client - The ERLCApi client.
|
|
644
|
+
*/
|
|
645
|
+
constructor(client: Client);
|
|
646
|
+
/**
|
|
647
|
+
* Executes a server command via the ER:LC API.
|
|
648
|
+
* @param command - The full command string to execute (e.g. `:pm jamie hello`).
|
|
649
|
+
* @returns A promise resolving to the API response string status.
|
|
650
|
+
*/
|
|
651
|
+
execute(command: string): Promise<string>;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* Represents a spawned vehicle in the ER:LC server.
|
|
656
|
+
* @public
|
|
657
|
+
*/
|
|
658
|
+
declare class Vehicle extends Base {
|
|
659
|
+
/**
|
|
660
|
+
* The name/model of the vehicle.
|
|
661
|
+
*/
|
|
662
|
+
name: string;
|
|
663
|
+
/**
|
|
664
|
+
* The UserId of the vehicle owner.
|
|
665
|
+
*/
|
|
666
|
+
ownerId: number;
|
|
667
|
+
/**
|
|
668
|
+
* The username of the vehicle owner.
|
|
669
|
+
*/
|
|
670
|
+
ownerUsername: string;
|
|
671
|
+
/**
|
|
672
|
+
* The Player instance representing the owner, if they are currently online.
|
|
673
|
+
*/
|
|
674
|
+
owner: Player;
|
|
675
|
+
/**
|
|
676
|
+
* The license plate text of the vehicle.
|
|
677
|
+
*/
|
|
678
|
+
plate: string;
|
|
679
|
+
/**
|
|
680
|
+
* The custom texture identifier, if any.
|
|
681
|
+
*/
|
|
682
|
+
texture?: string;
|
|
683
|
+
/**
|
|
684
|
+
* The hexadecimal color code of the vehicle.
|
|
685
|
+
*/
|
|
686
|
+
colorHex: string;
|
|
687
|
+
/**
|
|
688
|
+
* The user-friendly color name of the vehicle.
|
|
689
|
+
*/
|
|
690
|
+
colorName: string;
|
|
691
|
+
/**
|
|
692
|
+
* Creates an instance of Vehicle.
|
|
693
|
+
* @param client - The ERLCApi client.
|
|
694
|
+
* @param data - The raw vehicle data to initialize.
|
|
695
|
+
*/
|
|
696
|
+
constructor(client: Client, data: RawVehicle);
|
|
697
|
+
/**
|
|
698
|
+
* Patches the Vehicle structure with new raw data.
|
|
699
|
+
* @param data - The new raw vehicle data.
|
|
700
|
+
* @returns This vehicle instance.
|
|
701
|
+
*/
|
|
702
|
+
_patch(data: RawVehicle): this;
|
|
703
|
+
/**
|
|
704
|
+
* Converts this Vehicle instance to raw JSON representation.
|
|
705
|
+
* @returns The raw vehicle data.
|
|
706
|
+
*/
|
|
707
|
+
toJSON(): RawVehicle;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Manager responsible for fetching, caching, and updating Vehicle structures.
|
|
712
|
+
* @public
|
|
713
|
+
*/
|
|
714
|
+
declare class VehicleManager {
|
|
715
|
+
private readonly client;
|
|
716
|
+
/**
|
|
717
|
+
* Map cache of spawned vehicles in the server, keyed by their license plate.
|
|
718
|
+
*/
|
|
719
|
+
cache: Map<string, Vehicle>;
|
|
720
|
+
/**
|
|
721
|
+
* Creates an instance of VehicleManager.
|
|
722
|
+
* @param client - The ERLCApi client.
|
|
723
|
+
*/
|
|
724
|
+
constructor(client: Client);
|
|
725
|
+
/**
|
|
726
|
+
* Fetches all active vehicles currently spawned in the game server.
|
|
727
|
+
* Updates the vehicle cache.
|
|
728
|
+
* @returns A promise resolving to a Map of active Vehicles.
|
|
729
|
+
*/
|
|
730
|
+
fetchAll(): Promise<Map<string, Vehicle>>;
|
|
731
|
+
/**
|
|
732
|
+
* Re-synchronizes the cache with the raw vehicle list from the API.
|
|
733
|
+
* Emits vehicleAdd, vehicleRemove, and vehicleUpdate events.
|
|
734
|
+
* @param rawVehicles - Raw vehicle list payload.
|
|
735
|
+
* @returns The updated Vehicle cache Map.
|
|
736
|
+
*/
|
|
737
|
+
updateCache(rawVehicles: RawVehicle[]): Map<string, Vehicle>;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Represents a logged command execution event.
|
|
742
|
+
* @public
|
|
743
|
+
*/
|
|
744
|
+
declare class CommandLog extends Base {
|
|
745
|
+
/**
|
|
746
|
+
* The player instance representing who ran the command.
|
|
747
|
+
*/
|
|
748
|
+
player: Player;
|
|
749
|
+
/**
|
|
750
|
+
* The UserId of the player who ran the command.
|
|
751
|
+
*/
|
|
752
|
+
playerId: number;
|
|
753
|
+
/**
|
|
754
|
+
* The username of the player who ran the command.
|
|
755
|
+
*/
|
|
756
|
+
playerUsername: string;
|
|
757
|
+
/**
|
|
758
|
+
* Unix timestamp of when the command was run.
|
|
759
|
+
*/
|
|
760
|
+
timestamp: number;
|
|
761
|
+
/**
|
|
762
|
+
* The full command string executed.
|
|
763
|
+
*/
|
|
764
|
+
command: string;
|
|
765
|
+
/**
|
|
766
|
+
* Creates an instance of CommandLog.
|
|
767
|
+
* @param client - The ERLCApi client.
|
|
768
|
+
* @param data - The raw command log data to initialize.
|
|
769
|
+
*/
|
|
770
|
+
constructor(client: Client, data: RawCommandLog);
|
|
771
|
+
/**
|
|
772
|
+
* Patches the CommandLog structure with new raw data.
|
|
773
|
+
* @param data - The new raw command log data.
|
|
774
|
+
* @returns This command log instance.
|
|
775
|
+
*/
|
|
776
|
+
_patch(data: RawCommandLog): this;
|
|
777
|
+
/**
|
|
778
|
+
* Converts this CommandLog instance to raw JSON representation.
|
|
779
|
+
* @returns The raw command log data.
|
|
780
|
+
*/
|
|
781
|
+
toJSON(): RawCommandLog;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* Manager responsible for fetching, caching, and updating CommandLog structures.
|
|
786
|
+
* @public
|
|
787
|
+
*/
|
|
788
|
+
declare class CommandLogManager {
|
|
789
|
+
private readonly client;
|
|
790
|
+
/**
|
|
791
|
+
* Map cache of logged commands, keyed by a composite `Player:Timestamp` key.
|
|
792
|
+
*/
|
|
793
|
+
cache: Map<string, CommandLog>;
|
|
794
|
+
/**
|
|
795
|
+
* Creates an instance of CommandLogManager.
|
|
796
|
+
* @param client - The ERLCApi client.
|
|
797
|
+
*/
|
|
798
|
+
constructor(client: Client);
|
|
799
|
+
/**
|
|
800
|
+
* Fetches all command logs from the game server.
|
|
801
|
+
* Updates the command log cache.
|
|
802
|
+
* @returns A promise resolving to a Map of CommandLogs.
|
|
803
|
+
*/
|
|
804
|
+
fetchAll(): Promise<Map<string, CommandLog>>;
|
|
805
|
+
/**
|
|
806
|
+
* Re-synchronizes the cache with the raw command logs.
|
|
807
|
+
* Emits command event for new logs.
|
|
808
|
+
* @param rawCommands - Raw command logs payload.
|
|
809
|
+
* @returns The updated CommandLog cache Map.
|
|
810
|
+
*/
|
|
811
|
+
updateCache(rawCommands: RawCommandLog[]): Map<string, CommandLog>;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Represents an active emergency call in the ER:LC server.
|
|
816
|
+
* @public
|
|
817
|
+
*/
|
|
818
|
+
declare class EmergencyCall extends Base {
|
|
819
|
+
/**
|
|
820
|
+
* The Player instance representing the caller.
|
|
821
|
+
*/
|
|
822
|
+
caller: Player;
|
|
823
|
+
/**
|
|
824
|
+
* The UserId of the player who made the emergency call.
|
|
825
|
+
*/
|
|
826
|
+
callerId: number;
|
|
827
|
+
/**
|
|
828
|
+
* The team associated with the emergency call (e.g., "Police", "Fire").
|
|
829
|
+
*/
|
|
830
|
+
team: string;
|
|
831
|
+
/**
|
|
832
|
+
* Array of UserIds of responders assigned to this call.
|
|
833
|
+
*/
|
|
834
|
+
playerIds: number[];
|
|
835
|
+
/**
|
|
836
|
+
* Array of Player instances of active responders assigned to this call.
|
|
837
|
+
*/
|
|
838
|
+
players: Player[];
|
|
839
|
+
/**
|
|
840
|
+
* The game position coordinates [x, y] of the call.
|
|
841
|
+
*/
|
|
842
|
+
position: number[];
|
|
843
|
+
/**
|
|
844
|
+
* Unix timestamp of when the call was started.
|
|
845
|
+
*/
|
|
846
|
+
startedAt: number;
|
|
847
|
+
/**
|
|
848
|
+
* The unique call number.
|
|
849
|
+
*/
|
|
850
|
+
callNumber: number;
|
|
851
|
+
/**
|
|
852
|
+
* The description text of the emergency call.
|
|
853
|
+
*/
|
|
854
|
+
description: string;
|
|
855
|
+
/**
|
|
856
|
+
* Positional description of where the call was made.
|
|
857
|
+
*/
|
|
858
|
+
positionDescriptor: string;
|
|
859
|
+
/**
|
|
860
|
+
* Creates an instance of EmergencyCall.
|
|
861
|
+
* @param client - The ERLCApi client.
|
|
862
|
+
* @param data - The raw emergency call data to initialize.
|
|
863
|
+
*/
|
|
864
|
+
constructor(client: Client, data: RawEmergencyCall);
|
|
865
|
+
/**
|
|
866
|
+
* Patches the EmergencyCall structure with new raw data.
|
|
867
|
+
* @param data - The new raw emergency call data.
|
|
868
|
+
* @returns This emergency call instance.
|
|
869
|
+
*/
|
|
870
|
+
_patch(data: RawEmergencyCall): this;
|
|
871
|
+
/**
|
|
872
|
+
* Converts this EmergencyCall instance to raw JSON representation.
|
|
873
|
+
* @returns The raw emergency call data.
|
|
874
|
+
*/
|
|
875
|
+
toJSON(): RawEmergencyCall;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* Manager responsible for fetching, caching, and updating active EmergencyCall structures.
|
|
880
|
+
* @public
|
|
881
|
+
*/
|
|
882
|
+
declare class EmergencyCallManager {
|
|
883
|
+
private readonly client;
|
|
884
|
+
/**
|
|
885
|
+
* Map cache of active emergency calls, keyed by call number.
|
|
886
|
+
*/
|
|
887
|
+
cache: Map<number, EmergencyCall>;
|
|
888
|
+
/**
|
|
889
|
+
* Creates an instance of EmergencyCallManager.
|
|
890
|
+
* @param client - The ERLCApi client.
|
|
891
|
+
*/
|
|
892
|
+
constructor(client: Client);
|
|
893
|
+
/**
|
|
894
|
+
* Fetches all active emergency calls from the game server.
|
|
895
|
+
* Updates the emergency call cache.
|
|
896
|
+
* @returns A promise resolving to a Map of active EmergencyCalls.
|
|
897
|
+
*/
|
|
898
|
+
fetchAll(): Promise<Map<number, EmergencyCall>>;
|
|
899
|
+
/**
|
|
900
|
+
* Re-synchronizes the cache with the raw emergency calls payload.
|
|
901
|
+
* Emits emergencyCallAdd, emergencyCallRemove, and emergencyCallUpdate events.
|
|
902
|
+
* @param rawCalls - Raw active emergency calls payload.
|
|
903
|
+
* @returns The updated EmergencyCall cache Map.
|
|
904
|
+
*/
|
|
905
|
+
updateCache(rawCalls: RawEmergencyCall[]): Map<number, EmergencyCall>;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* Represents a log of a player death event (kill).
|
|
910
|
+
* @public
|
|
911
|
+
*/
|
|
912
|
+
declare class KillLog extends Base {
|
|
913
|
+
/**
|
|
914
|
+
* The Player instance representing the player who was killed.
|
|
915
|
+
*/
|
|
916
|
+
killed: Player;
|
|
917
|
+
/**
|
|
918
|
+
* The UserId of the player who was killed.
|
|
919
|
+
*/
|
|
920
|
+
killedId: number;
|
|
921
|
+
/**
|
|
922
|
+
* The Roblox username of the player who was killed.
|
|
923
|
+
*/
|
|
924
|
+
killedUsername: string;
|
|
925
|
+
/**
|
|
926
|
+
* The Player instance representing the player who did the killing.
|
|
927
|
+
*/
|
|
928
|
+
killer: Player;
|
|
929
|
+
/**
|
|
930
|
+
* The UserId of the player who did the killing.
|
|
931
|
+
*/
|
|
932
|
+
killerId: number;
|
|
933
|
+
/**
|
|
934
|
+
* The Roblox username of the player who did the killing.
|
|
935
|
+
*/
|
|
936
|
+
killerUsername: string;
|
|
937
|
+
/**
|
|
938
|
+
* Unix timestamp of when the kill occurred.
|
|
939
|
+
*/
|
|
940
|
+
timestamp: number;
|
|
941
|
+
/**
|
|
942
|
+
* Creates an instance of KillLog.
|
|
943
|
+
* @param client - The ERLCApi client.
|
|
944
|
+
* @param data - The raw kill log data.
|
|
945
|
+
*/
|
|
946
|
+
constructor(client: Client, data: RawKillLog);
|
|
947
|
+
/**
|
|
948
|
+
* Patches the KillLog structure with new raw data.
|
|
949
|
+
* @param data - The new raw kill log data.
|
|
950
|
+
* @returns This kill log instance.
|
|
951
|
+
*/
|
|
952
|
+
_patch(data: RawKillLog): this;
|
|
953
|
+
/**
|
|
954
|
+
* Converts this KillLog instance to raw JSON representation.
|
|
955
|
+
* @returns The raw kill log data.
|
|
956
|
+
*/
|
|
957
|
+
toJSON(): RawKillLog;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* Manager responsible for fetching, caching, and updating KillLog structures.
|
|
962
|
+
* @public
|
|
963
|
+
*/
|
|
964
|
+
declare class KillLogManager {
|
|
965
|
+
private readonly client;
|
|
966
|
+
/**
|
|
967
|
+
* Map cache of logged kills, keyed by a composite `Killer:Killed:Timestamp` key.
|
|
968
|
+
*/
|
|
969
|
+
cache: Map<string, KillLog>;
|
|
970
|
+
/**
|
|
971
|
+
* Creates an instance of KillLogManager.
|
|
972
|
+
* @param client - The ERLCApi client.
|
|
973
|
+
*/
|
|
974
|
+
constructor(client: Client);
|
|
975
|
+
/**
|
|
976
|
+
* Fetches all kill logs from the game server.
|
|
977
|
+
* Updates the kill log cache.
|
|
978
|
+
* @returns A promise resolving to a Map of KillLogs.
|
|
979
|
+
*/
|
|
980
|
+
fetchAll(): Promise<Map<string, KillLog>>;
|
|
981
|
+
/**
|
|
982
|
+
* Re-synchronizes the cache with the raw kill logs.
|
|
983
|
+
* Emits a kill event for new logs.
|
|
984
|
+
* @param rawCommands - Raw kill logs payload.
|
|
985
|
+
* @returns The updated KillLog cache Map.
|
|
986
|
+
*/
|
|
987
|
+
updateCache(rawCommands: RawKillLog[]): Map<string, KillLog>;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* Represents a request for moderation help (moderator call) in the ER:LC server.
|
|
992
|
+
* @public
|
|
993
|
+
*/
|
|
994
|
+
declare class ModCall extends Base {
|
|
995
|
+
/**
|
|
996
|
+
* The Player instance representing the caller.
|
|
997
|
+
*/
|
|
998
|
+
caller: Player;
|
|
999
|
+
/**
|
|
1000
|
+
* The UserId of the player who made the moderator call.
|
|
1001
|
+
*/
|
|
1002
|
+
callerId: number;
|
|
1003
|
+
/**
|
|
1004
|
+
* The Roblox username of the caller.
|
|
1005
|
+
*/
|
|
1006
|
+
callerUsername: string;
|
|
1007
|
+
/**
|
|
1008
|
+
* Unix timestamp of the moderator call.
|
|
1009
|
+
*/
|
|
1010
|
+
timestamp: number;
|
|
1011
|
+
/**
|
|
1012
|
+
* The Player instance representing the moderator who responded, if any.
|
|
1013
|
+
*/
|
|
1014
|
+
moderator?: Player;
|
|
1015
|
+
/**
|
|
1016
|
+
* The UserId of the moderator who responded, if any.
|
|
1017
|
+
*/
|
|
1018
|
+
moderatorId?: number;
|
|
1019
|
+
/**
|
|
1020
|
+
* The Roblox username of the moderator who responded, if any.
|
|
1021
|
+
*/
|
|
1022
|
+
moderatorUsername?: string;
|
|
1023
|
+
/**
|
|
1024
|
+
* Creates an instance of ModCall.
|
|
1025
|
+
* @param client - The ERLCApi client.
|
|
1026
|
+
* @param data - The raw moderator call data.
|
|
1027
|
+
*/
|
|
1028
|
+
constructor(client: Client, data: RawModCall);
|
|
1029
|
+
/**
|
|
1030
|
+
* Patches the ModCall structure with new raw data.
|
|
1031
|
+
* @param data - The new raw moderator call data.
|
|
1032
|
+
* @returns This moderator call instance.
|
|
1033
|
+
*/
|
|
1034
|
+
_patch(data: RawModCall): this;
|
|
1035
|
+
/**
|
|
1036
|
+
* Converts this ModCall instance to raw JSON representation.
|
|
1037
|
+
* @returns The raw moderator call data.
|
|
1038
|
+
*/
|
|
1039
|
+
toJSON(): RawModCall;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
/**
|
|
1043
|
+
* Manager responsible for fetching, caching, and updating ModCall structures.
|
|
1044
|
+
* @public
|
|
1045
|
+
*/
|
|
1046
|
+
declare class ModCallManager {
|
|
1047
|
+
private readonly client;
|
|
1048
|
+
/**
|
|
1049
|
+
* Map cache of logged moderator calls, keyed by a composite `Caller:Timestamp` key.
|
|
1050
|
+
*/
|
|
1051
|
+
cache: Map<string, ModCall>;
|
|
1052
|
+
/**
|
|
1053
|
+
* Creates an instance of ModCallManager.
|
|
1054
|
+
* @param client - The ERLCApi client.
|
|
1055
|
+
*/
|
|
1056
|
+
constructor(client: Client);
|
|
1057
|
+
/**
|
|
1058
|
+
* Fetches all moderator calls from the game server.
|
|
1059
|
+
* Updates the moderator call cache.
|
|
1060
|
+
* @returns A promise resolving to a Map of ModCalls.
|
|
1061
|
+
*/
|
|
1062
|
+
fetchAll(): Promise<Map<string, ModCall>>;
|
|
1063
|
+
/**
|
|
1064
|
+
* Re-synchronizes the cache with the raw moderator calls.
|
|
1065
|
+
* Emits a modCall event for new calls.
|
|
1066
|
+
* @param rawCommands - Raw moderator calls payload.
|
|
1067
|
+
* @returns The updated ModCall cache Map.
|
|
1068
|
+
*/
|
|
1069
|
+
updateCache(rawCommands: RawModCall[]): Map<string, ModCall>;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
/**
|
|
1073
|
+
* Event names emitted by the ERLCApi Client.
|
|
1074
|
+
* @public
|
|
1075
|
+
*/
|
|
1076
|
+
declare enum ERLCEvents {
|
|
1077
|
+
/** Emitted when a periodic server poll finishes. */
|
|
1078
|
+
poll = "POLL",
|
|
1079
|
+
/** Emitted when server details are updated. */
|
|
1080
|
+
serverUpdate = "SERVER_UPDATE",
|
|
1081
|
+
/** Emitted when server details are first loaded. */
|
|
1082
|
+
serverCreate = "SERVER_CREATE",
|
|
1083
|
+
/** Emitted when a player joins the server. */
|
|
1084
|
+
playerJoin = "PLAYER_JOIN",
|
|
1085
|
+
/** Emitted when a player's data (e.g. location, team) updates. */
|
|
1086
|
+
playerUpdate = "PLAYER_UPDATE",
|
|
1087
|
+
/** Emitted when a player leaves the server. */
|
|
1088
|
+
playerLeave = "PLAYER_LEAVE",
|
|
1089
|
+
/** Emitted when a vehicle is spawned. */
|
|
1090
|
+
vehicleAdd = "VEHICLE_ADD",
|
|
1091
|
+
/** Emitted when a vehicle is despawned. */
|
|
1092
|
+
vehicleRemove = "VEHICLE_REMOVE",
|
|
1093
|
+
/** Emitted when a vehicle's data updates. */
|
|
1094
|
+
vehicleUpdate = "VEHICLE_UPDATE",
|
|
1095
|
+
/** Emitted when a server command is run. */
|
|
1096
|
+
command = "COMMAND",
|
|
1097
|
+
/** Emitted when a player requests moderator assistance. */
|
|
1098
|
+
modCall = "MOD_CALL",
|
|
1099
|
+
/** Emitted when a player is killed. */
|
|
1100
|
+
kill = "KILL",
|
|
1101
|
+
/** Emitted when an emergency call is created. */
|
|
1102
|
+
emergencyCallAdd = "EMERGENCY_CALL_ADD",
|
|
1103
|
+
/** Emitted when an emergency call is cleared. */
|
|
1104
|
+
emergencyCallRemove = "EMERGENCY_CALL_REMOVE",
|
|
1105
|
+
/** Emitted when an emergency call is updated. */
|
|
1106
|
+
emergencyCallUpdate = "EMERGENCY_CALL_UPDATE"
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* Interface mapping client event names to their callback parameters.
|
|
1110
|
+
* @public
|
|
1111
|
+
*/
|
|
1112
|
+
interface ClientEvents {
|
|
1113
|
+
/** Emitted when a periodic server poll finishes. */
|
|
1114
|
+
[ERLCEvents.poll]: [server: RawServerData];
|
|
1115
|
+
/** Emitted when server details are updated. */
|
|
1116
|
+
[ERLCEvents.serverUpdate]: [oldServer: Server | null, newServer: Server];
|
|
1117
|
+
/** Emitted when server details are first loaded. */
|
|
1118
|
+
[ERLCEvents.serverCreate]: [server: Server];
|
|
1119
|
+
/** Emitted when a player joins the server. */
|
|
1120
|
+
[ERLCEvents.playerJoin]: [player: Player];
|
|
1121
|
+
/** Emitted when a player's data updates. */
|
|
1122
|
+
[ERLCEvents.playerUpdate]: [oldPlayer: Player | null, newPlayer: Player];
|
|
1123
|
+
/** Emitted when a player leaves the server. */
|
|
1124
|
+
[ERLCEvents.playerLeave]: [player: Player];
|
|
1125
|
+
/** Emitted when a vehicle is spawned. */
|
|
1126
|
+
[ERLCEvents.vehicleAdd]: [vehicle: Vehicle];
|
|
1127
|
+
/** Emitted when a vehicle is despawned. */
|
|
1128
|
+
[ERLCEvents.vehicleRemove]: [vehicle: Vehicle];
|
|
1129
|
+
/** Emitted when a vehicle's data updates. */
|
|
1130
|
+
[ERLCEvents.vehicleUpdate]: [oldVehicle: Vehicle | null, newVehicle: Vehicle];
|
|
1131
|
+
/** Emitted when a server command is run. */
|
|
1132
|
+
[ERLCEvents.command]: [log: CommandLog];
|
|
1133
|
+
/** Emitted when a player requests moderator assistance. */
|
|
1134
|
+
[ERLCEvents.modCall]: [call: ModCall];
|
|
1135
|
+
/** Emitted when a player is killed. */
|
|
1136
|
+
[ERLCEvents.kill]: [kill: KillLog];
|
|
1137
|
+
/** Emitted when an emergency call is created. */
|
|
1138
|
+
[ERLCEvents.emergencyCallAdd]: [call: EmergencyCall];
|
|
1139
|
+
/** Emitted when an emergency call is cleared. */
|
|
1140
|
+
[ERLCEvents.emergencyCallRemove]: [call: EmergencyCall];
|
|
1141
|
+
/** Emitted when an emergency call is updated. */
|
|
1142
|
+
[ERLCEvents.emergencyCallUpdate]: [oldCall: EmergencyCall | null, newCall: EmergencyCall];
|
|
1143
|
+
/** Emitted when an error is caught during polling or gateway operations. */
|
|
1144
|
+
error: [error: unknown];
|
|
1145
|
+
}
|
|
1146
|
+
/**
|
|
1147
|
+
* The main client for interacting with the ER:LC API and gateway.
|
|
1148
|
+
* @public
|
|
1149
|
+
*/
|
|
1150
|
+
declare class Client extends EventEmitter<ClientEvents> {
|
|
1151
|
+
options: ClientOptions;
|
|
1152
|
+
/** REST Manager for sending manual requests to the ER:LC API. */
|
|
1153
|
+
rest: RestManager;
|
|
1154
|
+
/** Manager for fetching and caching general server configuration. */
|
|
1155
|
+
server: ServerManager;
|
|
1156
|
+
/** Manager for player caching, joining, and management actions. */
|
|
1157
|
+
players: PlayerManager;
|
|
1158
|
+
/** Manager for executing server-side console commands. */
|
|
1159
|
+
commands: CommandManager;
|
|
1160
|
+
/** Manager for spawned vehicles cache and events. */
|
|
1161
|
+
vehicles: VehicleManager;
|
|
1162
|
+
/** Manager for command execution log events. */
|
|
1163
|
+
commandLogs: CommandLogManager;
|
|
1164
|
+
/** Manager for active emergency calls. */
|
|
1165
|
+
emergencyCalls: EmergencyCallManager;
|
|
1166
|
+
/** Manager for kill logs. */
|
|
1167
|
+
killLogs: KillLogManager;
|
|
1168
|
+
/** Manager for moderator call logs. */
|
|
1169
|
+
modCalls: ModCallManager;
|
|
1170
|
+
/** Webhook Gateway server instance, if enabled. */
|
|
1171
|
+
private readonly gateway?;
|
|
1172
|
+
/**
|
|
1173
|
+
* Creates an instance of Client.
|
|
1174
|
+
* @param options - The ClientOptions configuration.
|
|
1175
|
+
*/
|
|
1176
|
+
constructor(options: ClientOptions);
|
|
1177
|
+
/**
|
|
1178
|
+
* Starts the periodic api-polling loop if enabled.
|
|
1179
|
+
*/
|
|
1180
|
+
private startPolling;
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* Webhook Server for handling real-time gateway events pushed by ER:LC.
|
|
1185
|
+
* @alpha
|
|
1186
|
+
*/
|
|
1187
|
+
declare class WebhookServer {
|
|
1188
|
+
private client;
|
|
1189
|
+
private server;
|
|
1190
|
+
/**
|
|
1191
|
+
* Creates an instance of WebhookServer.
|
|
1192
|
+
* @param client - The ERLCApi client.
|
|
1193
|
+
*/
|
|
1194
|
+
constructor(client: Client);
|
|
1195
|
+
/**
|
|
1196
|
+
* Starts listening for incoming webhook events.
|
|
1197
|
+
*/
|
|
1198
|
+
listen(): void;
|
|
1199
|
+
/**
|
|
1200
|
+
* Internally processes gateway event payload.
|
|
1201
|
+
* @param payload - Raw JSON payload received.
|
|
1202
|
+
*/
|
|
1203
|
+
private handleGatewayEvent;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
/**
|
|
1207
|
+
* Error thrown when an invalid ER:LC Server API Key is provided.
|
|
1208
|
+
* @public
|
|
1209
|
+
*/
|
|
1210
|
+
declare class InvalidServerKeyError extends Error {
|
|
1211
|
+
/**
|
|
1212
|
+
* Creates an instance of InvalidServerKeyError.
|
|
1213
|
+
* @param message - The error message. Defaults to 'Invalid Server API Key.'.
|
|
1214
|
+
*/
|
|
1215
|
+
constructor(message?: string);
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
export { Base, Client, type ClientEvents, type ClientOptions, CommandLog, CommandLogManager, CommandManager, ERLCEvents, EmergencyCall, EmergencyCallManager, InvalidServerKeyError, KillLog, KillLogManager, ModCall, ModCallManager, Player, PlayerManager, type RawCommandLog, type RawEmergencyCall, type RawJoinLog, type RawKillLog, type RawModCall, type RawPlayerData, type RawServerData, type RawStaffData, type RawVehicle, RestManager, Server, ServerManager, Vehicle, VehicleManager, WebhookServer };
|