clashofclans.js 3.0.0-dev.392ca4c → 3.0.0-dev.ec60c82

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.
@@ -1,12 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RESTManager = void 0;
4
- const RequestHandler_1 = require("./RequestHandler");
4
+ const node_events_1 = require("node:events");
5
5
  const Util_1 = require("../util/Util");
6
+ const Constants_1 = require("../util/Constants");
7
+ const RequestHandler_1 = require("./RequestHandler");
6
8
  /** Represents a REST Manager of the client. */
7
- class RESTManager {
9
+ class RESTManager extends node_events_1.EventEmitter {
8
10
  constructor(options) {
9
- this.handler = new RequestHandler_1.RequestHandler(options);
11
+ super();
12
+ this.requestHandler = new RequestHandler_1.RequestHandler(options)
13
+ .on(Constants_1.RestEvents.Debug, this.emit.bind(this, Constants_1.RestEvents.Debug))
14
+ .on(Constants_1.RestEvents.Error, this.emit.bind(this, Constants_1.RestEvents.Error))
15
+ .on(Constants_1.RestEvents.RateLimited, this.emit.bind(this, Constants_1.RestEvents.RateLimited));
10
16
  }
11
17
  /** Contains various general-purpose utility methods. */
12
18
  get util() {
@@ -21,122 +27,122 @@ class RESTManager {
21
27
  * ```
22
28
  */
23
29
  login(options) {
24
- return this.handler.init(options);
30
+ return this.requestHandler.init(options);
25
31
  }
26
32
  /** Set Clash of Clans API keys. */
27
33
  setKeys(keys) {
28
- this.handler.setKeys(keys);
34
+ this.requestHandler.setKeys(keys);
29
35
  return this;
30
36
  }
31
37
  /** Search all clans by name and/or filtering the results using various criteria. */
32
38
  getClans(query, options) {
33
- return this.handler.request(`/clans${Util_1.Util.queryString(query)}`, options);
39
+ return this.requestHandler.request(`/clans${Util_1.Util.queryString(query)}`, options);
34
40
  }
35
41
  /** Get info about a clan. */
36
42
  getClan(clanTag, options) {
37
- return this.handler.request(`/clans/${Util_1.Util.encodeURI(clanTag)}`, options);
43
+ return this.requestHandler.request(`/clans/${Util_1.Util.encodeURI(clanTag)}`, options);
38
44
  }
39
45
  /** Get list of clan members. */
40
46
  getClanMembers(clanTag, options) {
41
47
  const query = Util_1.Util.queryString(options);
42
- return this.handler.request(`/clans/${Util_1.Util.encodeURI(clanTag)}/members${query}`, options);
48
+ return this.requestHandler.request(`/clans/${Util_1.Util.encodeURI(clanTag)}/members${query}`, options);
43
49
  }
44
50
  /** Get clan war log. */
45
51
  getClanWarLog(clanTag, options) {
46
52
  const query = Util_1.Util.queryString(options);
47
- return this.handler.request(`/clans/${Util_1.Util.encodeURI(clanTag)}/warlog${query}`, options);
53
+ return this.requestHandler.request(`/clans/${Util_1.Util.encodeURI(clanTag)}/warlog${query}`, options);
48
54
  }
49
55
  /** Get info about currently running war in the clan. */
50
56
  getCurrentWar(clanTag, options) {
51
- return this.handler.request(`/clans/${Util_1.Util.encodeURI(clanTag)}/currentwar`, options);
57
+ return this.requestHandler.request(`/clans/${Util_1.Util.encodeURI(clanTag)}/currentwar`, options);
52
58
  }
53
59
  /** Get info about clan war league. */
54
60
  getClanWarLeagueGroup(clanTag, options) {
55
- return this.handler.request(`/clans/${Util_1.Util.encodeURI(clanTag)}/currentwar/leaguegroup`, options);
61
+ return this.requestHandler.request(`/clans/${Util_1.Util.encodeURI(clanTag)}/currentwar/leaguegroup`, options);
56
62
  }
57
63
  /** Get info about a CWL round by WarTag. */
58
64
  getClanWarLeagueRound(warTag, options) {
59
- return this.handler.request(`/clanwarleagues/wars/${Util_1.Util.encodeURI(warTag)}`, options);
65
+ return this.requestHandler.request(`/clanwarleagues/wars/${Util_1.Util.encodeURI(warTag)}`, options);
60
66
  }
61
67
  /** Get info about a player by tag. */
62
68
  getPlayer(playerTag, options) {
63
- return this.handler.request(`/players/${Util_1.Util.encodeURI(playerTag)}`, options);
69
+ return this.requestHandler.request(`/players/${Util_1.Util.encodeURI(playerTag)}`, options);
64
70
  }
65
71
  /** Verify Player API token that can be found from the Game settings. */
66
72
  verifyPlayerToken(playerTag, token, options) {
67
73
  const opts = { method: 'POST', body: JSON.stringify({ token }), ...options };
68
- return this.handler.request(`/players/${Util_1.Util.encodeURI(playerTag)}/verifytoken`, opts);
74
+ return this.requestHandler.request(`/players/${Util_1.Util.encodeURI(playerTag)}/verifytoken`, opts);
69
75
  }
70
76
  /** Get list of Leagues. */
71
77
  getLeagues(options) {
72
78
  const query = Util_1.Util.queryString(options);
73
- return this.handler.request(`/leagues${query}`, options);
79
+ return this.requestHandler.request(`/leagues${query}`, options);
74
80
  }
75
81
  /** Get a League info. */
76
82
  getLeague(leagueId, options) {
77
- return this.handler.request(`/leagues/${leagueId}`, options);
83
+ return this.requestHandler.request(`/leagues/${leagueId}`, options);
78
84
  }
79
85
  /** Get Legend League season Ids. */
80
86
  getLeagueSeasons(leagueId, options) {
81
87
  const query = Util_1.Util.queryString(options);
82
- return this.handler.request(`/leagues/${leagueId}/seasons${query}`, options);
88
+ return this.requestHandler.request(`/leagues/${leagueId}/seasons${query}`, options);
83
89
  }
84
90
  /** Get Legend League season rankings by season Id. */
85
91
  getSeasonRankings(leagueId, seasonId, options) {
86
92
  const query = Util_1.Util.queryString(options);
87
- return this.handler.request(`/leagues/${leagueId}/seasons/${seasonId}${query}`, options);
93
+ return this.requestHandler.request(`/leagues/${leagueId}/seasons/${seasonId}${query}`, options);
88
94
  }
89
95
  /** Get list of Clan War Leagues. */
90
96
  getWarLeagues(options) {
91
97
  const query = Util_1.Util.queryString(options);
92
- return this.handler.request(`/warleagues${query}`, options);
98
+ return this.requestHandler.request(`/warleagues${query}`, options);
93
99
  }
94
100
  /** Get info about a Clan War League. */
95
101
  getWarLeague(leagueId, options) {
96
- return this.handler.request(`/warleagues/${leagueId}`, options);
102
+ return this.requestHandler.request(`/warleagues/${leagueId}`, options);
97
103
  }
98
104
  /** Get list of Locations. */
99
105
  getLocations(options) {
100
106
  const query = Util_1.Util.queryString(options);
101
- return this.handler.request(`/locations${query}`, options);
107
+ return this.requestHandler.request(`/locations${query}`, options);
102
108
  }
103
109
  /** Get info about a Location. */
104
110
  getLocation(locationId, options) {
105
- return this.handler.request(`/locations/${locationId}`, options);
111
+ return this.requestHandler.request(`/locations/${locationId}`, options);
106
112
  }
107
113
  /** Get clan rankings for a specific location. */
108
114
  getClanRanks(locationId, options) {
109
115
  const query = Util_1.Util.queryString(options);
110
- return this.handler.request(`/locations/${locationId}/rankings/clans${query}`, options);
116
+ return this.requestHandler.request(`/locations/${locationId}/rankings/clans${query}`, options);
111
117
  }
112
118
  /** Get player rankings for a specific location. */
113
119
  getPlayerRanks(locationId, options) {
114
120
  const query = Util_1.Util.queryString(options);
115
- return this.handler.request(`/locations/${locationId}/rankings/players${query}`, options);
121
+ return this.requestHandler.request(`/locations/${locationId}/rankings/players${query}`, options);
116
122
  }
117
123
  /** Get clan versus rankings for a specific location. */
118
124
  getVersusClanRanks(locationId, options) {
119
125
  const query = Util_1.Util.queryString(options);
120
- return this.handler.request(`/locations/${locationId}/rankings/clans-versus${query}`, options);
126
+ return this.requestHandler.request(`/locations/${locationId}/rankings/clans-versus${query}`, options);
121
127
  }
122
128
  /** Get player versus rankings for a specific location. */
123
129
  getVersusPlayerRanks(locationId, options) {
124
130
  const query = Util_1.Util.queryString(options);
125
- return this.handler.request(`/locations/${locationId}/rankings/players-versus${query}`, options);
131
+ return this.requestHandler.request(`/locations/${locationId}/rankings/players-versus${query}`, options);
126
132
  }
127
133
  /** Get list of clan labels. */
128
134
  getClanLabels(options) {
129
135
  const query = Util_1.Util.queryString(options);
130
- return this.handler.request(`/labels/clans${query}`, options);
136
+ return this.requestHandler.request(`/labels/clans${query}`, options);
131
137
  }
132
138
  /** Get list of player labels. */
133
139
  getPlayerLabels(options) {
134
140
  const query = Util_1.Util.queryString(options);
135
- return this.handler.request(`/labels/players${query}`, options);
141
+ return this.requestHandler.request(`/labels/players${query}`, options);
136
142
  }
137
143
  /** Get info about gold pass season. */
138
144
  getGoldPassSeason(options) {
139
- return this.handler.request('/goldpass/seasons/current', options);
145
+ return this.requestHandler.request('/goldpass/seasons/current', options);
140
146
  }
141
147
  }
142
148
  exports.RESTManager = RESTManager;
@@ -1,6 +1,34 @@
1
+ /// <reference types="node" />
2
+ import { EventEmitter } from 'node:events';
1
3
  import { Response, RequestOptions, LoginOptions, RequestHandlerOptions } from '../types';
2
- /** Represents a Request Handler. */
3
- export declare class RequestHandler {
4
+ import { IRestEvents } from './RESTManager';
5
+ export interface RequestHandler {
6
+ emit: (<K extends keyof IRestEvents>(event: K, ...args: IRestEvents[K]) => boolean) & (<S extends string | symbol>(event: Exclude<S, keyof IRestEvents>, ...args: any[]) => boolean);
7
+ off: (<K extends keyof IRestEvents>(event: K, listener: (...args: IRestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof IRestEvents>, listener: (...args: any[]) => void) => this);
8
+ on: (<K extends keyof IRestEvents>(event: K, listener: (...args: IRestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof IRestEvents>, listener: (...args: any[]) => void) => this);
9
+ once: (<K extends keyof IRestEvents>(event: K, listener: (...args: IRestEvents[K]) => void) => this) & (<S extends string | symbol>(event: Exclude<S, keyof IRestEvents>, listener: (...args: any[]) => void) => this);
10
+ removeAllListeners: (<K extends keyof IRestEvents>(event?: K) => this) & (<S extends string | symbol>(event?: Exclude<S, keyof IRestEvents>) => this);
11
+ /**
12
+ * Emitted for general debugging information.
13
+ * @public
14
+ * @event
15
+ */
16
+ debug: string;
17
+ /**
18
+ * Emitted when the client encounters an error.
19
+ * @public
20
+ * @event
21
+ */
22
+ error: string;
23
+ /**
24
+ * Emitted when the client is rate limited.
25
+ * @public
26
+ * @event
27
+ */
28
+ rateLimited: string;
29
+ }
30
+ /** Represents the class that manages handlers for endpoints. */
31
+ export declare class RequestHandler extends EventEmitter {
4
32
  #private;
5
33
  private email;
6
34
  private password;
@@ -16,16 +16,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  var _RequestHandler_keyIndex;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.RequestHandler = void 0;
19
+ const node_https_1 = __importDefault(require("node:https"));
20
+ const node_events_1 = require("node:events");
21
+ const node_fetch_1 = __importDefault(require("node-fetch"));
19
22
  const Constants_1 = require("../util/Constants");
20
- const HTTPError_1 = require("./HTTPError");
21
23
  const Store_1 = require("../util/Store");
22
- const node_fetch_1 = __importDefault(require("node-fetch"));
23
- const https_1 = __importDefault(require("https"));
24
+ const HTTPError_1 = require("./HTTPError");
24
25
  const IP_REGEX = /\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}/g;
25
- const agent = new https_1.default.Agent({ keepAlive: true });
26
- /** Represents a Request Handler. */
27
- class RequestHandler {
26
+ const agent = new node_https_1.default.Agent({ keepAlive: true });
27
+ /** Represents the class that manages handlers for endpoints. */
28
+ class RequestHandler extends node_events_1.EventEmitter {
28
29
  constructor(options) {
30
+ super();
29
31
  _RequestHandler_keyIndex.set(this, 0); // eslint-disable-line
30
32
  this.keys = options?.keys ?? [];
31
33
  this.retryLimit = options?.retryLimit ?? 0;
@@ -89,6 +91,10 @@ class RequestHandler {
89
91
  if (!res?.ok && this.rejectIfNotValid) {
90
92
  throw new HTTPError_1.HTTPError(data, res?.status ?? 504, path, maxAge, options.method);
91
93
  }
94
+ if (res?.status === 429) {
95
+ this.emit(Constants_1.RestEvents.RateLimited, path, res.status, options.method);
96
+ }
97
+ this.emit(Constants_1.RestEvents.Debug, path, res?.status ?? 504, options.method);
92
98
  if (this.cached && maxAge > 0 && options.cache !== false && res?.ok) {
93
99
  await this.cached.set(path, { data, ttl: Date.now() + maxAge, status: res.status }, maxAge);
94
100
  }
@@ -1,7 +1,7 @@
1
1
  import { APIClan, OverrideOptions } from '../types';
2
+ import { Client } from '../client/Client';
2
3
  import { ChatLanguage } from './ChatLanguage';
3
4
  import { ClanMember } from './ClanMember';
4
- import { Client } from '../client/Client';
5
5
  import { WarLeague } from './WarLeague';
6
6
  import type { Player } from './Player';
7
7
  import { Location } from './Location';
@@ -1,9 +1,9 @@
1
1
  import { APIPlayer, OverrideOptions } from '../types';
2
+ import { Client } from '../client/Client';
2
3
  import { LegendStatistics } from './LegendStatistics';
3
4
  import { Achievement } from './Achievement';
4
5
  import { Hero, Spell, Troop } from './Unit';
5
6
  import { PlayerClan } from './PlayerClan';
6
- import { Client } from '../client/Client';
7
7
  import { League } from './League';
8
8
  import { Label } from './Label';
9
9
  /** Represents a Clash of Clans Player. */
@@ -1,6 +1,6 @@
1
1
  import { APIClanRanking, APIClanVersusRanking, APIPlayerRanking, APIPlayerVersusRanking } from '../types';
2
- import { PlayerClan } from './PlayerClan';
3
2
  import { Client } from '../client/Client';
3
+ import { PlayerClan } from './PlayerClan';
4
4
  import { Location } from './Location';
5
5
  import { League } from './League';
6
6
  import { Badge } from './Badge';
@@ -39,8 +39,6 @@ export declare class Unit {
39
39
  seasonal: boolean;
40
40
  /** Damage per second of this unit. */
41
41
  dps: number;
42
- /** Resource type of this unit. */
43
- resourceType: string;
44
42
  /** Training time of this unit. */
45
43
  trainingTime: number;
46
44
  /** @internal */
@@ -25,7 +25,6 @@ class Unit {
25
25
  this.unlockBuilding = original.unlock.building;
26
26
  this.unlockBuildingLevel = original.unlock.buildingLevel;
27
27
  this.dps = rawUnit.dps[this.level - 1];
28
- this.resourceType = rawSuperUnit.resource;
29
28
  this.trainingTime = rawUnit.trainingTime;
30
29
  const origin = data.troops.find((troop) => troop.village === 'home' && troop.name === original.name);
31
30
  this.level = origin.level;
@@ -49,7 +48,6 @@ class Unit {
49
48
  this.upgradeCost = rawUnit.upgrade.cost[this.level - 1] ?? 0;
50
49
  this.upgradeTime = rawUnit.upgrade.time[this.level - 1] ?? 0;
51
50
  this.dps = rawUnit.dps[this.level - 1];
52
- this.resourceType = rawUnit.resourceType;
53
51
  this.trainingTime = rawUnit.trainingTime;
54
52
  if (rawUnit.category === 'hero')
55
53
  this.regenerationTime = rawUnit.regenerationTimes[this.level - 1];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,9 +1,9 @@
1
1
  import { QueueThrottler, BatchThrottler } from '../rest/Throttler';
2
2
  export interface Store<T = any> {
3
- set(key: string, value: T, ttl?: number): boolean | Promise<boolean>;
4
- get(key: string): T | null | Promise<T | null>;
5
- delete(key: string): boolean | Promise<boolean>;
6
- clear(): void | Promise<void>;
3
+ set: (key: string, value: T, ttl?: number) => boolean | Promise<boolean>;
4
+ get: (key: string) => T | null | Promise<T | null>;
5
+ delete: (key: string) => boolean | Promise<boolean>;
6
+ clear: () => void | Promise<void>;
7
7
  }
8
8
  /** Options for a {@link Client} */
9
9
  export interface ClientOptions {
@@ -24,25 +24,60 @@ export declare const Leagues: number[];
24
24
  export declare const WarLeagues: number[];
25
25
  export declare const FriendlyWarPreparationTimes: readonly [number, number, number, number, number, number, number, number, number, number, number, number];
26
26
  export declare const PollingEvents: {
27
- readonly NewSeasonStart: "newSeasonStart";
28
27
  readonly ClanLoopStart: "clanLoopStart";
29
28
  readonly ClanLoopEnd: "clanLoopEnd";
30
29
  readonly PlayerLoopStart: "playerLoopStart";
31
30
  readonly PlayerLoopEnd: "playerLoopEnd";
32
31
  readonly WarLoopStart: "warLoopEnd";
33
32
  readonly WarLoopEnd: "warLoopEnd";
33
+ readonly NewSeasonStart: "newSeasonStart";
34
34
  readonly MaintenanceStart: "maintenanceStart";
35
35
  readonly MaintenanceEnd: "maintenanceEnd";
36
36
  readonly Error: "error";
37
37
  readonly Debug: "debug";
38
38
  };
39
+ export declare const ClientEvents: {
40
+ readonly Error: "error";
41
+ readonly Debug: "debug";
42
+ };
43
+ export declare const RestEvents: {
44
+ readonly Error: "error";
45
+ readonly Debug: "debug";
46
+ readonly RateLimited: "rateLimited";
47
+ };
39
48
  export declare const CWLRounds: {
40
49
  readonly PreviousRound: "warEnded";
41
50
  readonly CurrentRound: "inWar";
42
51
  readonly NextRound: "preparation";
43
52
  };
44
53
  export declare const RawData: {
45
- RawUnits: {
54
+ RawUnits: ({
55
+ id: number;
56
+ name: string;
57
+ housingSpace: number;
58
+ village: string;
59
+ category: string;
60
+ subCategory: string;
61
+ unlock: {
62
+ hall: number;
63
+ cost: number;
64
+ time: number;
65
+ resource: string;
66
+ building: string;
67
+ buildingLevel: number;
68
+ };
69
+ trainingTime: number;
70
+ regenerationTimes: number[];
71
+ dps: number[];
72
+ upgrade: {
73
+ cost: number[];
74
+ time: number[];
75
+ resource: string;
76
+ };
77
+ seasonal: boolean;
78
+ levels: number[];
79
+ resourceType?: undefined;
80
+ } | {
46
81
  id: number;
47
82
  name: string;
48
83
  housingSpace: number;
@@ -68,7 +103,7 @@ export declare const RawData: {
68
103
  };
69
104
  seasonal: boolean;
70
105
  levels: number[];
71
- }[];
106
+ })[];
72
107
  RawSuperUnits: {
73
108
  name: string;
74
109
  id: number;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.RawData = exports.CWLRounds = exports.PollingEvents = exports.FriendlyWarPreparationTimes = exports.WarLeagues = exports.Leagues = exports.LegendLeagueId = exports.UnrankedLeagueData = exports.HeroPets = exports.Heroes = exports.BuilderTroops = exports.Spells = exports.DarkElixirSpells = exports.ElixirSpells = exports.SuperTroops = exports.SiegeMachines = exports.HomeTroops = exports.DarkElixirTroops = exports.ElixirTroops = exports.DevSiteAPIBaseURL = exports.APIBaseURL = void 0;
6
+ exports.RawData = exports.CWLRounds = exports.RestEvents = exports.ClientEvents = exports.PollingEvents = exports.FriendlyWarPreparationTimes = exports.WarLeagues = exports.Leagues = exports.LegendLeagueId = exports.UnrankedLeagueData = exports.HeroPets = exports.Heroes = exports.BuilderTroops = exports.Spells = exports.DarkElixirSpells = exports.ElixirSpells = exports.SuperTroops = exports.SiegeMachines = exports.HomeTroops = exports.DarkElixirTroops = exports.ElixirTroops = exports.DevSiteAPIBaseURL = exports.APIBaseURL = void 0;
7
7
  const raw_json_1 = __importDefault(require("../util/raw.json"));
8
8
  exports.APIBaseURL = 'https://api.clashofclans.com/v1';
9
9
  exports.DevSiteAPIBaseURL = 'https://developer.clashofclans.com/api';
@@ -122,18 +122,27 @@ exports.FriendlyWarPreparationTimes = [
122
122
  1000 * 60 * 5
123
123
  ];
124
124
  exports.PollingEvents = {
125
- NewSeasonStart: 'newSeasonStart',
126
125
  ClanLoopStart: 'clanLoopStart',
127
126
  ClanLoopEnd: 'clanLoopEnd',
128
127
  PlayerLoopStart: 'playerLoopStart',
129
128
  PlayerLoopEnd: 'playerLoopEnd',
130
129
  WarLoopStart: 'warLoopEnd',
131
130
  WarLoopEnd: 'warLoopEnd',
131
+ NewSeasonStart: 'newSeasonStart',
132
132
  MaintenanceStart: 'maintenanceStart',
133
133
  MaintenanceEnd: 'maintenanceEnd',
134
134
  Error: 'error',
135
135
  Debug: 'debug'
136
136
  };
137
+ exports.ClientEvents = {
138
+ Error: 'error',
139
+ Debug: 'debug'
140
+ };
141
+ exports.RestEvents = {
142
+ Error: 'error',
143
+ Debug: 'debug',
144
+ RateLimited: 'rateLimited'
145
+ };
137
146
  exports.CWLRounds = {
138
147
  PreviousRound: 'warEnded',
139
148
  CurrentRound: 'inWar',
package/dist/util/Util.js CHANGED
@@ -114,8 +114,8 @@ class Util extends null {
114
114
  }
115
115
  /** Parse in-game army link into troops and spells count with respective Id's. */
116
116
  static parseArmyLink(link) {
117
- const unitsMatches = link.match(/u(?<units>[\d+x-]+)/);
118
- const spellsMatches = link.match(/s(?<spells>[\d+x-]+)/);
117
+ const unitsMatches = /u(?<units>[\d+x-]+)/.exec(link);
118
+ const spellsMatches = /s(?<spells>[\d+x-]+)/.exec(link);
119
119
  const unitsPart = unitsMatches?.groups?.unit?.split('-') ?? [];
120
120
  const spellParts = spellsMatches?.groups?.spells?.split('-') ?? [];
121
121
  const units = unitsPart