clashofclans.js 3.0.2 → 3.1.0-dev.202ebf7
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/dist/client/Client.d.ts +11 -9
- package/dist/client/Client.js +23 -14
- package/dist/client/PollingClient.d.ts +3 -2
- package/dist/client/PollingClient.js +8 -4
- package/dist/index.mjs +0 -4
- package/dist/rest/RESTManager.d.ts +10 -6
- package/dist/rest/RESTManager.js +15 -6
- package/dist/rest/RequestHandler.js +6 -6
- package/dist/struct/Clan.d.ts +12 -11
- package/dist/struct/Clan.js +6 -7
- package/dist/struct/ClanMember.d.ts +4 -2
- package/dist/struct/ClanMember.js +1 -0
- package/dist/struct/LegendStatistics.d.ts +4 -4
- package/dist/struct/LegendStatistics.js +2 -2
- package/dist/struct/Player.d.ts +7 -5
- package/dist/struct/Player.js +3 -2
- package/dist/struct/Ranking.d.ts +17 -13
- package/dist/struct/Ranking.js +5 -1
- package/dist/struct/Unit.js +7 -4
- package/dist/struct/index.d.ts +0 -4
- package/dist/struct/index.js +0 -4
- package/dist/types/api.d.ts +46 -17
- package/dist/types/lib.d.ts +3 -0
- package/dist/util/Constants.d.ts +85 -1
- package/dist/util/Constants.js +1 -1
- package/dist/util/raw.json +1 -1
- package/package.json +1 -1
package/dist/client/Client.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { ClanSearchOptions, SearchOptions, ClientOptions, LoginOptions, Override
|
|
|
4
4
|
import { CWLRounds, ClientEvents } from '../util/Constants';
|
|
5
5
|
import { RESTManager } from '../rest/RESTManager';
|
|
6
6
|
import { Util } from '../util/Util';
|
|
7
|
-
import { Clan, ClanMember, ClanWar, ClanWarLog,
|
|
7
|
+
import { Clan, ClanMember, ClanWar, ClanWarLog, Location, Player, RankedClan, RankedPlayer, SeasonRankedPlayer, GoldPassSeason, ClanWarLeagueGroup } from '../struct';
|
|
8
8
|
import { CapitalRaidSeason } from '../struct/CapitalRaidSeason';
|
|
9
9
|
interface IClientEvents {
|
|
10
10
|
[ClientEvents.Error]: [error: unknown];
|
|
@@ -113,7 +113,9 @@ export declare class Client extends EventEmitter {
|
|
|
113
113
|
/** Verify Player API token that can be found from the Game settings. */
|
|
114
114
|
verifyPlayerToken(playerTag: string, token: string, options?: OverrideOptions): Promise<boolean>;
|
|
115
115
|
/** Get a list of Leagues. */
|
|
116
|
-
getLeagues(options?: SearchOptions): Promise<
|
|
116
|
+
getLeagues(options?: SearchOptions): Promise<import("../types").APILeague[]>;
|
|
117
|
+
/** Get a list of Leagues. */
|
|
118
|
+
getBuilderBaseLeagues(options?: SearchOptions): Promise<import("../types").APIBuilderBaseLeague[]>;
|
|
117
119
|
/** Get a list of Capital Leagues. */
|
|
118
120
|
getCapitalLeagues(options?: SearchOptions): Promise<import("../types").APICapitalLeague[]>;
|
|
119
121
|
/** Get Legend League season Ids. */
|
|
@@ -121,7 +123,7 @@ export declare class Client extends EventEmitter {
|
|
|
121
123
|
/** Get Legend League season rankings by season Id. */
|
|
122
124
|
getSeasonRankings(seasonId: string, options?: SearchOptions): Promise<SeasonRankedPlayer[]>;
|
|
123
125
|
/** Get list of Clan War Leagues. */
|
|
124
|
-
getWarLeagues(options?: SearchOptions): Promise<
|
|
126
|
+
getWarLeagues(options?: SearchOptions): Promise<import("../types").APIWarLeague[]>;
|
|
125
127
|
/** Get list of Locations. */
|
|
126
128
|
getLocations(options?: SearchOptions): Promise<Location[]>;
|
|
127
129
|
/**
|
|
@@ -137,17 +139,17 @@ export declare class Client extends EventEmitter {
|
|
|
137
139
|
*/
|
|
138
140
|
getPlayerRanks(locationId: number | 'global', options?: SearchOptions): Promise<RankedPlayer[]>;
|
|
139
141
|
/**
|
|
140
|
-
* Get clan
|
|
142
|
+
* Get clan builder base rankings for a specific location.
|
|
141
143
|
*
|
|
142
144
|
* For global ranking, use `global` as `locationId`.
|
|
143
145
|
*/
|
|
144
|
-
|
|
146
|
+
getBuilderBaseClanRanks(locationId: number | 'global', options?: SearchOptions): Promise<RankedClan[]>;
|
|
145
147
|
/**
|
|
146
|
-
* Get player
|
|
148
|
+
* Get player builder base rankings for a specific location.
|
|
147
149
|
*
|
|
148
150
|
* For global ranking, use `global` as `locationId`.
|
|
149
151
|
*/
|
|
150
|
-
|
|
152
|
+
getBuilderBasePlayerRanks(locationId: number | 'global', options?: SearchOptions): Promise<RankedPlayer[]>;
|
|
151
153
|
/**
|
|
152
154
|
* Get clan capital rankings for a specific location.
|
|
153
155
|
*
|
|
@@ -155,9 +157,9 @@ export declare class Client extends EventEmitter {
|
|
|
155
157
|
*/
|
|
156
158
|
getClanCapitalRanks(locationId: number | 'global', options?: SearchOptions): Promise<import("../types").APIClanCapitalRanking[]>;
|
|
157
159
|
/** Get list of clan labels. */
|
|
158
|
-
getClanLabels(options?: SearchOptions): Promise<
|
|
160
|
+
getClanLabels(options?: SearchOptions): Promise<import("../types").APILabel[]>;
|
|
159
161
|
/** Get list of player labels. */
|
|
160
|
-
getPlayerLabels(options?: SearchOptions): Promise<
|
|
162
|
+
getPlayerLabels(options?: SearchOptions): Promise<import("../types").APILabel[]>;
|
|
161
163
|
/** Get info about gold pass season. */
|
|
162
164
|
getGoldPassSeason(options?: OverrideOptions): Promise<GoldPassSeason>;
|
|
163
165
|
}
|
package/dist/client/Client.js
CHANGED
|
@@ -92,13 +92,17 @@ class Client extends node_events_1.EventEmitter {
|
|
|
92
92
|
async getCurrentWar(clanTag, options) {
|
|
93
93
|
const args = typeof clanTag === 'string' ? { clanTag } : { clanTag: clanTag.clanTag, round: clanTag.round };
|
|
94
94
|
try {
|
|
95
|
-
|
|
95
|
+
const data = await this.getClanWar(args.clanTag, options);
|
|
96
|
+
if (data.state === 'notInWar') {
|
|
97
|
+
return await this.getLeagueWar({ clanTag: args.clanTag, round: args.round }, options);
|
|
98
|
+
}
|
|
99
|
+
return data;
|
|
96
100
|
}
|
|
97
|
-
catch (
|
|
98
|
-
if (
|
|
101
|
+
catch (err) {
|
|
102
|
+
if (err instanceof HTTPError_1.HTTPError && err.status === 403) {
|
|
99
103
|
return this.getLeagueWar({ clanTag: args.clanTag, round: args.round }, options);
|
|
100
104
|
}
|
|
101
|
-
throw
|
|
105
|
+
throw err;
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
108
|
/**
|
|
@@ -184,7 +188,12 @@ class Client extends node_events_1.EventEmitter {
|
|
|
184
188
|
/** Get a list of Leagues. */
|
|
185
189
|
async getLeagues(options) {
|
|
186
190
|
const { data } = await this.rest.getLeagues(options);
|
|
187
|
-
return data.items
|
|
191
|
+
return data.items;
|
|
192
|
+
}
|
|
193
|
+
/** Get a list of Leagues. */
|
|
194
|
+
async getBuilderBaseLeagues(options) {
|
|
195
|
+
const { data } = await this.rest.getBuilderBaseLeagues(options);
|
|
196
|
+
return data.items;
|
|
188
197
|
}
|
|
189
198
|
/** Get a list of Capital Leagues. */
|
|
190
199
|
async getCapitalLeagues(options) {
|
|
@@ -204,7 +213,7 @@ class Client extends node_events_1.EventEmitter {
|
|
|
204
213
|
/** Get list of Clan War Leagues. */
|
|
205
214
|
async getWarLeagues(options) {
|
|
206
215
|
const { data } = await this.rest.getWarLeagues(options);
|
|
207
|
-
return data.items
|
|
216
|
+
return data.items;
|
|
208
217
|
}
|
|
209
218
|
/** Get list of Locations. */
|
|
210
219
|
async getLocations(options) {
|
|
@@ -230,21 +239,21 @@ class Client extends node_events_1.EventEmitter {
|
|
|
230
239
|
return data.items.map((entry) => new struct_1.RankedPlayer(this, entry));
|
|
231
240
|
}
|
|
232
241
|
/**
|
|
233
|
-
* Get clan
|
|
242
|
+
* Get clan builder base rankings for a specific location.
|
|
234
243
|
*
|
|
235
244
|
* For global ranking, use `global` as `locationId`.
|
|
236
245
|
*/
|
|
237
|
-
async
|
|
238
|
-
const { data } = await this.rest.
|
|
246
|
+
async getBuilderBaseClanRanks(locationId, options) {
|
|
247
|
+
const { data } = await this.rest.getBuilderBaseClanRanks(locationId, options);
|
|
239
248
|
return data.items.map((entry) => new struct_1.RankedClan(entry));
|
|
240
249
|
}
|
|
241
250
|
/**
|
|
242
|
-
* Get player
|
|
251
|
+
* Get player builder base rankings for a specific location.
|
|
243
252
|
*
|
|
244
253
|
* For global ranking, use `global` as `locationId`.
|
|
245
254
|
*/
|
|
246
|
-
async
|
|
247
|
-
const { data } = await this.rest.
|
|
255
|
+
async getBuilderBasePlayerRanks(locationId, options) {
|
|
256
|
+
const { data } = await this.rest.getBuilderBasePlayerRanks(locationId, options);
|
|
248
257
|
return data.items.map((entry) => new struct_1.RankedPlayer(this, entry));
|
|
249
258
|
}
|
|
250
259
|
/**
|
|
@@ -259,12 +268,12 @@ class Client extends node_events_1.EventEmitter {
|
|
|
259
268
|
/** Get list of clan labels. */
|
|
260
269
|
async getClanLabels(options) {
|
|
261
270
|
const { data } = await this.rest.getClanLabels(options);
|
|
262
|
-
return data.items
|
|
271
|
+
return data.items;
|
|
263
272
|
}
|
|
264
273
|
/** Get list of player labels. */
|
|
265
274
|
async getPlayerLabels(options) {
|
|
266
275
|
const { data } = await this.rest.getPlayerLabels(options);
|
|
267
|
-
return data.items
|
|
276
|
+
return data.items;
|
|
268
277
|
}
|
|
269
278
|
/** Get info about gold pass season. */
|
|
270
279
|
async getGoldPassSeason(options) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Clan, ClanWar, Player } from '../struct';
|
|
2
|
-
import {
|
|
2
|
+
import { PollingClientOptions } from '../types';
|
|
3
3
|
import { PollingEvents } from '../util/Constants';
|
|
4
4
|
import { Client } from './Client';
|
|
5
5
|
/**
|
|
@@ -13,13 +13,14 @@ export declare class PollingClient extends Client {
|
|
|
13
13
|
private readonly _clanTags;
|
|
14
14
|
private readonly _playerTags;
|
|
15
15
|
private readonly _warTags;
|
|
16
|
+
private readonly _pollingInterval;
|
|
16
17
|
private readonly _clans;
|
|
17
18
|
private readonly _players;
|
|
18
19
|
private readonly _wars;
|
|
19
20
|
private readonly _pollingEvents;
|
|
20
21
|
inMaintenance: boolean;
|
|
21
22
|
private _maintenanceStartTime;
|
|
22
|
-
constructor(options?:
|
|
23
|
+
constructor(options?: PollingClientOptions);
|
|
23
24
|
/** Initialize the PollingEvent Manager to start pulling the data by polling api. */
|
|
24
25
|
init(): Promise<string[]>;
|
|
25
26
|
/** Add clan tags to clan polling events. */
|
|
@@ -27,6 +27,10 @@ class PollingClient extends Client_1.Client {
|
|
|
27
27
|
};
|
|
28
28
|
this.inMaintenance = Boolean(false);
|
|
29
29
|
this._maintenanceStartTime = null;
|
|
30
|
+
if (options?.pollingInterval && !isNaN(options.pollingInterval)) {
|
|
31
|
+
throw new Error('The property "pollingInterval" must be a type of number.');
|
|
32
|
+
}
|
|
33
|
+
this._pollingInterval = Math.max(options?.pollingInterval ?? 1000, 1000);
|
|
30
34
|
}
|
|
31
35
|
/** Initialize the PollingEvent Manager to start pulling the data by polling api. */
|
|
32
36
|
async init() {
|
|
@@ -147,7 +151,7 @@ class PollingClient extends Client_1.Client {
|
|
|
147
151
|
return this;
|
|
148
152
|
}
|
|
149
153
|
async maintenanceHandler() {
|
|
150
|
-
setTimeout(this.maintenanceHandler.bind(this),
|
|
154
|
+
setTimeout(this.maintenanceHandler.bind(this), this._pollingInterval).unref();
|
|
151
155
|
if (!(this.listenerCount(Constants_1.PollingEvents.MaintenanceStart) && this.listenerCount(Constants_1.PollingEvents.MaintenanceEnd)))
|
|
152
156
|
return;
|
|
153
157
|
try {
|
|
@@ -184,21 +188,21 @@ class PollingClient extends Client_1.Client {
|
|
|
184
188
|
for (const tag of this._clanTags)
|
|
185
189
|
await this.runClanUpdate(tag);
|
|
186
190
|
this.emit(Constants_1.PollingEvents.ClanLoopEnd);
|
|
187
|
-
setTimeout(this.clanUpdateHandler.bind(this),
|
|
191
|
+
setTimeout(this.clanUpdateHandler.bind(this), this._pollingInterval);
|
|
188
192
|
}
|
|
189
193
|
async playerUpdateHandler() {
|
|
190
194
|
this.emit(Constants_1.PollingEvents.PlayerLoopStart);
|
|
191
195
|
for (const tag of this._playerTags)
|
|
192
196
|
await this.runPlayerUpdate(tag);
|
|
193
197
|
this.emit(Constants_1.PollingEvents.PlayerLoopEnd);
|
|
194
|
-
setTimeout(this.playerUpdateHandler.bind(this),
|
|
198
|
+
setTimeout(this.playerUpdateHandler.bind(this), this._pollingInterval);
|
|
195
199
|
}
|
|
196
200
|
async warUpdateHandler() {
|
|
197
201
|
this.emit(Constants_1.PollingEvents.WarLoopStart);
|
|
198
202
|
for (const tag of this._warTags)
|
|
199
203
|
await this.runWarUpdate(tag);
|
|
200
204
|
this.emit(Constants_1.PollingEvents.WarLoopEnd);
|
|
201
|
-
setTimeout(this.warUpdateHandler.bind(this),
|
|
205
|
+
setTimeout(this.warUpdateHandler.bind(this), this._pollingInterval);
|
|
202
206
|
}
|
|
203
207
|
async runClanUpdate(tag) {
|
|
204
208
|
if (this.inMaintenance)
|
package/dist/index.mjs
CHANGED
|
@@ -10,7 +10,6 @@ export const CWLRounds = mod.CWLRounds;
|
|
|
10
10
|
export const CacheStore = mod.CacheStore;
|
|
11
11
|
export const CapitalRaidSeason = mod.CapitalRaidSeason;
|
|
12
12
|
export const CapitalRaidSeasonMember = mod.CapitalRaidSeasonMember;
|
|
13
|
-
export const ChatLanguage = mod.ChatLanguage;
|
|
14
13
|
export const Clan = mod.Clan;
|
|
15
14
|
export const ClanCapital = mod.ClanCapital;
|
|
16
15
|
export const ClanMember = mod.ClanMember;
|
|
@@ -37,8 +36,6 @@ export const HeroPets = mod.HeroPets;
|
|
|
37
36
|
export const Heroes = mod.Heroes;
|
|
38
37
|
export const HomeTroops = mod.HomeTroops;
|
|
39
38
|
export const Icon = mod.Icon;
|
|
40
|
-
export const Label = mod.Label;
|
|
41
|
-
export const League = mod.League;
|
|
42
39
|
export const Leagues = mod.Leagues;
|
|
43
40
|
export const LegendLeagueId = mod.LegendLeagueId;
|
|
44
41
|
export const LegendStatistics = mod.LegendStatistics;
|
|
@@ -66,6 +63,5 @@ export const Unit = mod.Unit;
|
|
|
66
63
|
export const UnrankedLeagueData = mod.UnrankedLeagueData;
|
|
67
64
|
export const Util = mod.Util;
|
|
68
65
|
export const WarClan = mod.WarClan;
|
|
69
|
-
export const WarLeague = mod.WarLeague;
|
|
70
66
|
export const WarLeagues = mod.WarLeagues;
|
|
71
67
|
export const WarLogClan = mod.WarLogClan;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from 'node:events';
|
|
3
3
|
import { Util } from '../util/Util';
|
|
4
|
-
import { APIClan, APIClanList, APIClanMemberList, APICapitalRaidSeasons, APIClanRankingList,
|
|
4
|
+
import { APIClan, APIClanList, APIClanMemberList, APICapitalRaidSeasons, APIClanRankingList, APIClanBuilderBaseRankingList, APIClanWar, APIClanWarLeagueGroup, APIClanWarLog, APIGoldPassSeason, APILabelList, APILeague, APILeagueList, APILeagueSeasonList, APILocation, APILocationList, APIPlayer, APIPlayerRankingList, APIPlayerSeasonRankingList, APIPlayerBuilderBaseRankingList, APIVerifyToken, APIWarLeague, APIWarLeagueList, SearchOptions, ClanSearchOptions, RESTOptions, OverrideOptions, LoginOptions, APICapitalLeagueList, APICapitalLeague, APIClanCapitalRankingList, APIBuilderBaseLeagueList, APIBuilderBaseLeague } from '../types';
|
|
5
5
|
import { RestEvents } from '../util/Constants';
|
|
6
6
|
import { RequestHandler } from './RequestHandler';
|
|
7
7
|
export interface IRestEvents {
|
|
@@ -67,7 +67,7 @@ export declare class RESTManager extends EventEmitter {
|
|
|
67
67
|
/** Get info about a CWL round by WarTag. */
|
|
68
68
|
getClanWarLeagueRound(warTag: string, options?: OverrideOptions): Promise<import("../types").Response<APIClanWar>>;
|
|
69
69
|
/** Retrieve clan's capital raid seasons. */
|
|
70
|
-
getCapitalRaidSeasons(tag: string, options?:
|
|
70
|
+
getCapitalRaidSeasons(tag: string, options?: SearchOptions): Promise<import("../types").Response<APICapitalRaidSeasons>>;
|
|
71
71
|
/** Get info about a player by tag. */
|
|
72
72
|
getPlayer(playerTag: string, options?: OverrideOptions): Promise<import("../types").Response<APIPlayer>>;
|
|
73
73
|
/** Verify Player API token that can be found from the Game settings. */
|
|
@@ -76,6 +76,10 @@ export declare class RESTManager extends EventEmitter {
|
|
|
76
76
|
getLeagues(options?: SearchOptions): Promise<import("../types").Response<APILeagueList>>;
|
|
77
77
|
/** Get a League info. */
|
|
78
78
|
getLeague(leagueId: string | number, options?: OverrideOptions): Promise<import("../types").Response<APILeague>>;
|
|
79
|
+
/** Get a list of builder base leagues. */
|
|
80
|
+
getBuilderBaseLeagues(options?: SearchOptions): Promise<import("../types").Response<APIBuilderBaseLeagueList>>;
|
|
81
|
+
/** Get a builder base league info. */
|
|
82
|
+
getBuilderBaseLeague(leagueId: string | number, options?: OverrideOptions): Promise<import("../types").Response<APIBuilderBaseLeague>>;
|
|
79
83
|
/** Get a list of Capital leagues. */
|
|
80
84
|
getCapitalLeagues(options?: SearchOptions): Promise<import("../types").Response<APICapitalLeagueList>>;
|
|
81
85
|
/** Get a Capital League info. */
|
|
@@ -96,10 +100,10 @@ export declare class RESTManager extends EventEmitter {
|
|
|
96
100
|
getClanRanks(locationId: number | string, options?: SearchOptions): Promise<import("../types").Response<APIClanRankingList>>;
|
|
97
101
|
/** Get player rankings for a specific location. */
|
|
98
102
|
getPlayerRanks(locationId: number | string, options?: SearchOptions): Promise<import("../types").Response<APIPlayerRankingList>>;
|
|
99
|
-
/** Get clan
|
|
100
|
-
|
|
101
|
-
/** Get player
|
|
102
|
-
|
|
103
|
+
/** Get clan builder base rankings for a specific location. */
|
|
104
|
+
getBuilderBaseClanRanks(locationId: number | string, options?: SearchOptions): Promise<import("../types").Response<APIClanBuilderBaseRankingList>>;
|
|
105
|
+
/** Get player builder base rankings for a specific location. */
|
|
106
|
+
getBuilderBasePlayerRanks(locationId: number | string, options?: SearchOptions): Promise<import("../types").Response<APIPlayerBuilderBaseRankingList>>;
|
|
103
107
|
/** Get clan capital rankings for a specific location. */
|
|
104
108
|
getClanCapitalRanks(locationId: number | string, options?: SearchOptions): Promise<import("../types").Response<APIClanCapitalRankingList>>;
|
|
105
109
|
/** Get list of clan labels. */
|
package/dist/rest/RESTManager.js
CHANGED
|
@@ -87,6 +87,15 @@ class RESTManager extends node_events_1.EventEmitter {
|
|
|
87
87
|
getLeague(leagueId, options) {
|
|
88
88
|
return this.requestHandler.request(`/leagues/${leagueId}`, options);
|
|
89
89
|
}
|
|
90
|
+
/** Get a list of builder base leagues. */
|
|
91
|
+
getBuilderBaseLeagues(options) {
|
|
92
|
+
const query = Util_1.Util.queryString(options);
|
|
93
|
+
return this.requestHandler.request(`/builderbaseleagues${query}`, options);
|
|
94
|
+
}
|
|
95
|
+
/** Get a builder base league info. */
|
|
96
|
+
getBuilderBaseLeague(leagueId, options) {
|
|
97
|
+
return this.requestHandler.request(`/builderbaseleagues/${leagueId}`, options);
|
|
98
|
+
}
|
|
90
99
|
/** Get a list of Capital leagues. */
|
|
91
100
|
getCapitalLeagues(options) {
|
|
92
101
|
const query = Util_1.Util.queryString(options);
|
|
@@ -134,15 +143,15 @@ class RESTManager extends node_events_1.EventEmitter {
|
|
|
134
143
|
const query = Util_1.Util.queryString(options);
|
|
135
144
|
return this.requestHandler.request(`/locations/${locationId}/rankings/players${query}`, options);
|
|
136
145
|
}
|
|
137
|
-
/** Get clan
|
|
138
|
-
|
|
146
|
+
/** Get clan builder base rankings for a specific location. */
|
|
147
|
+
getBuilderBaseClanRanks(locationId, options) {
|
|
139
148
|
const query = Util_1.Util.queryString(options);
|
|
140
|
-
return this.requestHandler.request(`/locations/${locationId}/rankings/clans-
|
|
149
|
+
return this.requestHandler.request(`/locations/${locationId}/rankings/clans-builder-base${query}`, options);
|
|
141
150
|
}
|
|
142
|
-
/** Get player
|
|
143
|
-
|
|
151
|
+
/** Get player builder base rankings for a specific location. */
|
|
152
|
+
getBuilderBasePlayerRanks(locationId, options) {
|
|
144
153
|
const query = Util_1.Util.queryString(options);
|
|
145
|
-
return this.requestHandler.request(`/locations/${locationId}/rankings/players-
|
|
154
|
+
return this.requestHandler.request(`/locations/${locationId}/rankings/players-builder-base${query}`, options);
|
|
146
155
|
}
|
|
147
156
|
/** Get clan capital rankings for a specific location. */
|
|
148
157
|
getClanCapitalRanks(locationId, options) {
|
|
@@ -145,7 +145,7 @@ class RequestHandler extends node_events_1.EventEmitter {
|
|
|
145
145
|
for (const key of this.keys) {
|
|
146
146
|
const res = await (0, node_fetch_1.default)(`${this.baseURL}/locations?limit=1`, {
|
|
147
147
|
method: 'GET',
|
|
148
|
-
timeout:
|
|
148
|
+
timeout: this.restRequestTimeout,
|
|
149
149
|
headers: { 'Authorization': `Bearer ${key}`, 'Content-Type': 'application/json' }
|
|
150
150
|
}).catch(() => null);
|
|
151
151
|
if (res?.status === 403) {
|
|
@@ -158,7 +158,7 @@ class RequestHandler extends node_events_1.EventEmitter {
|
|
|
158
158
|
async login() {
|
|
159
159
|
const res = await (0, node_fetch_1.default)(`${Constants_1.DevSiteAPIBaseURL}/login`, {
|
|
160
160
|
method: 'POST',
|
|
161
|
-
timeout:
|
|
161
|
+
timeout: this.restRequestTimeout,
|
|
162
162
|
headers: { 'Content-Type': 'application/json' },
|
|
163
163
|
body: JSON.stringify({ email: this.email, password: this.password })
|
|
164
164
|
});
|
|
@@ -173,7 +173,7 @@ class RequestHandler extends node_events_1.EventEmitter {
|
|
|
173
173
|
async getKeys(cookie, ip) {
|
|
174
174
|
const res = await (0, node_fetch_1.default)(`${Constants_1.DevSiteAPIBaseURL}/apikey/list`, {
|
|
175
175
|
method: 'POST',
|
|
176
|
-
timeout:
|
|
176
|
+
timeout: this.restRequestTimeout,
|
|
177
177
|
headers: { 'Content-Type': 'application/json', cookie }
|
|
178
178
|
});
|
|
179
179
|
const data = await res.json();
|
|
@@ -215,7 +215,7 @@ class RequestHandler extends node_events_1.EventEmitter {
|
|
|
215
215
|
async revokeKey(keyId, cookie) {
|
|
216
216
|
const res = await (0, node_fetch_1.default)(`${Constants_1.DevSiteAPIBaseURL}/apikey/revoke`, {
|
|
217
217
|
method: 'POST',
|
|
218
|
-
timeout:
|
|
218
|
+
timeout: this.restRequestTimeout,
|
|
219
219
|
body: JSON.stringify({ id: keyId }),
|
|
220
220
|
headers: { 'Content-Type': 'application/json', cookie }
|
|
221
221
|
});
|
|
@@ -224,7 +224,7 @@ class RequestHandler extends node_events_1.EventEmitter {
|
|
|
224
224
|
async createKey(cookie, ip) {
|
|
225
225
|
const res = await (0, node_fetch_1.default)(`${Constants_1.DevSiteAPIBaseURL}/apikey/create`, {
|
|
226
226
|
method: 'POST',
|
|
227
|
-
timeout:
|
|
227
|
+
timeout: this.restRequestTimeout,
|
|
228
228
|
headers: { 'Content-Type': 'application/json', cookie },
|
|
229
229
|
body: JSON.stringify({
|
|
230
230
|
cidrRanges: [ip],
|
|
@@ -244,7 +244,7 @@ class RequestHandler extends node_events_1.EventEmitter {
|
|
|
244
244
|
return props.cidrs[0].match(IP_REGEX)[0];
|
|
245
245
|
}
|
|
246
246
|
catch {
|
|
247
|
-
const body = await (0, node_fetch_1.default)('https://api.ipify.org', { timeout:
|
|
247
|
+
const body = await (0, node_fetch_1.default)('https://api.ipify.org', { timeout: this.restRequestTimeout }).then((res) => res.text());
|
|
248
248
|
return body.match(IP_REGEX)?.[0] ?? null;
|
|
249
249
|
}
|
|
250
250
|
}
|
package/dist/struct/Clan.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { APICapitalLeague, APIClan, OverrideOptions } from '../types';
|
|
1
|
+
import { APICapitalLeague, APIChatLanguage, APIClan, APILabel, APIWarLeague, OverrideOptions } from '../types';
|
|
2
2
|
import { Client } from '../client/Client';
|
|
3
|
-
import { ChatLanguage } from './ChatLanguage';
|
|
4
3
|
import { ClanMember } from './ClanMember';
|
|
5
|
-
import { WarLeague } from './WarLeague';
|
|
6
4
|
import type { Player } from './Player';
|
|
7
5
|
import { Location } from './Location';
|
|
8
|
-
import { Label } from './Label';
|
|
9
6
|
import { Badge } from './Badge';
|
|
10
7
|
import { ClanCapital } from './ClanCapital';
|
|
11
8
|
/** Represents a Clan. */
|
|
@@ -22,7 +19,7 @@ export declare class Clan {
|
|
|
22
19
|
/** The location of this clan. */
|
|
23
20
|
location: Location | null;
|
|
24
21
|
/** The clan's trophy count. */
|
|
25
|
-
chatLanguage:
|
|
22
|
+
chatLanguage: APIChatLanguage | null;
|
|
26
23
|
/** The clan's Badge. */
|
|
27
24
|
badge: Badge;
|
|
28
25
|
/** The clan's level. */
|
|
@@ -31,12 +28,16 @@ export declare class Clan {
|
|
|
31
28
|
points: number;
|
|
32
29
|
/** The clan's capital points. */
|
|
33
30
|
capitalPoints: number;
|
|
34
|
-
/** The clan's
|
|
35
|
-
|
|
31
|
+
/** The clan's builder base trophy count. */
|
|
32
|
+
builderBasePoints: number;
|
|
33
|
+
/** @deprecated */
|
|
34
|
+
versusPoints?: number | null;
|
|
36
35
|
/** The minimum trophies required to apply to this clan. */
|
|
37
36
|
requiredTrophies: number;
|
|
38
|
-
/** The minimum
|
|
39
|
-
|
|
37
|
+
/** The minimum builder base trophies required to apply to this clan. */
|
|
38
|
+
requiredBuilderBaseTrophies: number | null;
|
|
39
|
+
/** @deprecated */
|
|
40
|
+
requiredVersusTrophies?: number | null;
|
|
40
41
|
/** The minimum hall level required to apply to this clan. */
|
|
41
42
|
requiredTownHallLevel: number | null;
|
|
42
43
|
/** The frequency for when this clan goes to war. */
|
|
@@ -52,11 +53,11 @@ export declare class Clan {
|
|
|
52
53
|
/** Indicates if the clan has a public war log. */
|
|
53
54
|
isWarLogPublic: boolean;
|
|
54
55
|
/** The clan's CWL league. */
|
|
55
|
-
warLeague:
|
|
56
|
+
warLeague: APIWarLeague | null;
|
|
56
57
|
/** The number of members in the clan. */
|
|
57
58
|
memberCount: number;
|
|
58
59
|
/** An array of {@link Label} that the clan has. */
|
|
59
|
-
labels:
|
|
60
|
+
labels: APILabel[];
|
|
60
61
|
/** The clan's Clan Capital information */
|
|
61
62
|
clanCapital: ClanCapital | null;
|
|
62
63
|
/** The clan's capital league. */
|
package/dist/struct/Clan.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Clan = void 0;
|
|
4
|
-
const ChatLanguage_1 = require("./ChatLanguage");
|
|
5
4
|
const ClanMember_1 = require("./ClanMember");
|
|
6
|
-
const WarLeague_1 = require("./WarLeague");
|
|
7
5
|
const Location_1 = require("./Location");
|
|
8
|
-
const Label_1 = require("./Label");
|
|
9
6
|
const Badge_1 = require("./Badge");
|
|
10
7
|
const ClanCapital_1 = require("./ClanCapital");
|
|
11
8
|
/** Represents a Clan. */
|
|
@@ -17,13 +14,15 @@ class Clan {
|
|
|
17
14
|
this.type = data.type;
|
|
18
15
|
this.description = data.description;
|
|
19
16
|
this.location = data.location ? new Location_1.Location(data.location) : null;
|
|
20
|
-
this.chatLanguage = data.chatLanguage
|
|
17
|
+
this.chatLanguage = data.chatLanguage ?? null;
|
|
21
18
|
this.badge = new Badge_1.Badge(data.badgeUrls);
|
|
22
19
|
this.level = data.clanLevel;
|
|
23
20
|
this.points = data.clanPoints;
|
|
24
|
-
this.
|
|
21
|
+
this.builderBasePoints = data.clanBuilderBasePoints;
|
|
22
|
+
this.versusPoints = data.clanVersusPoints ?? null;
|
|
25
23
|
this.requiredTrophies = data.requiredTrophies;
|
|
26
24
|
this.requiredTownHallLevel = data.requiredTownhallLevel ?? null;
|
|
25
|
+
this.requiredBuilderBaseTrophies = data.requiredBuilderBaseTrophies ?? null;
|
|
27
26
|
this.requiredVersusTrophies = data.requiredVersusTrophies ?? null;
|
|
28
27
|
this.warFrequency = data.warFrequency;
|
|
29
28
|
this.warWinStreak = data.warWinStreak;
|
|
@@ -31,9 +30,9 @@ class Clan {
|
|
|
31
30
|
this.warTies = data.warTies ?? null;
|
|
32
31
|
this.warLosses = data.warLosses ?? null;
|
|
33
32
|
this.isWarLogPublic = data.isWarLogPublic;
|
|
34
|
-
this.warLeague = data.warLeague
|
|
33
|
+
this.warLeague = data.warLeague ?? null;
|
|
35
34
|
this.memberCount = data.members;
|
|
36
|
-
this.labels = data.labels
|
|
35
|
+
this.labels = data.labels;
|
|
37
36
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
38
37
|
this.clanCapital = Object.keys(data.clanCapital ?? {}).length > 0 ? new ClanCapital_1.ClanCapital(data.clanCapital) : null;
|
|
39
38
|
this.isFamilyFriendly = data.isFamilyFriendly;
|
|
@@ -15,8 +15,10 @@ export declare class ClanMember {
|
|
|
15
15
|
league: League;
|
|
16
16
|
/** The member's trophy count. */
|
|
17
17
|
trophies: number;
|
|
18
|
-
/** The member's
|
|
19
|
-
|
|
18
|
+
/** The member's builder base trophy count. */
|
|
19
|
+
builderBaseTrophies: number | null;
|
|
20
|
+
/** @deprecated */
|
|
21
|
+
versusTrophies?: number | null;
|
|
20
22
|
/** The member's rank in the clan. */
|
|
21
23
|
clanRank: number;
|
|
22
24
|
/** The member's rank before the last leader-board change. */
|
|
@@ -14,6 +14,7 @@ class ClanMember {
|
|
|
14
14
|
// eslint-disable-next-line
|
|
15
15
|
this.league = new League_1.League(data.league ?? Constants_1.UnrankedLeagueData);
|
|
16
16
|
this.trophies = data.trophies;
|
|
17
|
+
this.builderBaseTrophies = data.builderBaseTrophies ?? null;
|
|
17
18
|
this.versusTrophies = data.versusTrophies ?? null;
|
|
18
19
|
this.clanRank = data.clanRank;
|
|
19
20
|
this.previousClanRank = data.previousClanRank;
|
|
@@ -10,9 +10,9 @@ export declare class LegendStatistics {
|
|
|
10
10
|
currentSeason: Season | null;
|
|
11
11
|
/** Legend statistics for this player's best season. */
|
|
12
12
|
bestSeason: Season | null;
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
|
|
13
|
+
/** Builder base Legend statistics for previous season. */
|
|
14
|
+
previousBuilderBaseSeason: Season | null;
|
|
15
|
+
/** Builder base Legend statistics for this player's best season. */
|
|
16
|
+
bestBuilderBaseSeason: Season | null;
|
|
17
17
|
constructor(data: APILegendStatistics);
|
|
18
18
|
}
|
|
@@ -10,8 +10,8 @@ class LegendStatistics {
|
|
|
10
10
|
// #blame-supercell
|
|
11
11
|
this.currentSeason = data.currentSeason?.rank ? new Season_1.Season(data.currentSeason) : null;
|
|
12
12
|
this.bestSeason = data.bestSeason ? new Season_1.Season(data.bestSeason) : null;
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
13
|
+
this.previousBuilderBaseSeason = data.previousBuilderBaseSeason ? new Season_1.Season(data.previousBuilderBaseSeason) : null;
|
|
14
|
+
this.bestBuilderBaseSeason = data.bestBuilderBaseSeason ? new Season_1.Season(data.bestBuilderBaseSeason) : null;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
exports.LegendStatistics = LegendStatistics;
|
package/dist/struct/Player.d.ts
CHANGED
|
@@ -31,11 +31,13 @@ export declare class Player {
|
|
|
31
31
|
defenseWins: number;
|
|
32
32
|
/** The player's builder hall level, or 0 if it hasn't been unlocked. */
|
|
33
33
|
builderHallLevel: number | null;
|
|
34
|
-
/** The player's
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
|
|
38
|
-
/** The
|
|
34
|
+
/** The player's builder base trophy count. */
|
|
35
|
+
builderBaseTrophies: number | null;
|
|
36
|
+
/** @deprecated */
|
|
37
|
+
versusTrophies?: number | null;
|
|
38
|
+
/** The player's best builder base trophies. */
|
|
39
|
+
bestBuilderBaseTrophies: number | null;
|
|
40
|
+
/** @deprecated */
|
|
39
41
|
versusBattleWins: number | null;
|
|
40
42
|
/** The player's donation count for this season. */
|
|
41
43
|
donations: number;
|
package/dist/struct/Player.js
CHANGED
|
@@ -23,9 +23,10 @@ class Player {
|
|
|
23
23
|
this.attackWins = data.attackWins;
|
|
24
24
|
this.defenseWins = data.defenseWins;
|
|
25
25
|
this.builderHallLevel = data.builderHallLevel ?? null;
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
26
|
+
this.builderBaseTrophies = data.builderBaseTrophies ?? null;
|
|
27
|
+
this.bestBuilderBaseTrophies = data.bestBuilderBaseTrophies ?? null;
|
|
28
28
|
this.versusBattleWins = data.versusBattleWins ?? null;
|
|
29
|
+
this.versusTrophies = data.versusTrophies ?? null;
|
|
29
30
|
this.donations = data.donations;
|
|
30
31
|
this.received = data.donationsReceived;
|
|
31
32
|
this.clanCapitalContributions = data.clanCapitalContributions;
|
package/dist/struct/Ranking.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APIClanRanking,
|
|
1
|
+
import { APIClanRanking, APIClanBuilderBaseRanking, APIPlayerRanking, APIPlayerBuilderBaseRanking } from '../types';
|
|
2
2
|
import { Client } from '../client/Client';
|
|
3
3
|
import { PlayerClan } from './PlayerClan';
|
|
4
4
|
import { Location } from './Location';
|
|
@@ -34,25 +34,27 @@ export declare class RankedPlayer {
|
|
|
34
34
|
tag: string;
|
|
35
35
|
/** The player's experience level. */
|
|
36
36
|
expLevel: number;
|
|
37
|
-
/** The player's trophy count. If retrieving info for
|
|
37
|
+
/** The player's trophy count. If retrieving info for builder base leader-boards, this will be `null`. */
|
|
38
38
|
trophies: number | null;
|
|
39
|
-
/** The player's attack wins. If retrieving info for
|
|
39
|
+
/** The player's attack wins. If retrieving info for builder base leader-boards, this will be `null`. */
|
|
40
40
|
attackWins: number | null;
|
|
41
|
-
/** The player's defense wins. If retrieving info for
|
|
41
|
+
/** The player's defense wins. If retrieving info for builder base leader-boards, this will be `null`. */
|
|
42
42
|
defenseWins: number | null;
|
|
43
|
-
/** The player's
|
|
44
|
-
|
|
45
|
-
/**
|
|
43
|
+
/** The player's builder base trophy count. If retrieving info for regular leader-boards, this will be `null`. */
|
|
44
|
+
builderBaseTrophies: number | null;
|
|
45
|
+
/** @deprecated */
|
|
46
46
|
versusBattleWins: number | null;
|
|
47
|
+
/** @deprecated */
|
|
48
|
+
versusTrophies?: number | null;
|
|
47
49
|
/** The player's rank in the clan leader-board. */
|
|
48
50
|
rank: number;
|
|
49
51
|
/** The player's rank before the last leader-board change. If retrieving info for legend league season, this will be `null`. */
|
|
50
52
|
previousRank: number | null;
|
|
51
53
|
/** The player's clan. */
|
|
52
54
|
clan: PlayerClan | null;
|
|
53
|
-
/** The player's league. If retrieving info for
|
|
55
|
+
/** The player's league. If retrieving info for builder base leader-boards, this will be `null`. */
|
|
54
56
|
league: League | null;
|
|
55
|
-
constructor(client: Client, data: APIPlayerRanking |
|
|
57
|
+
constructor(client: Client, data: APIPlayerRanking | APIPlayerBuilderBaseRanking);
|
|
56
58
|
/** Get player's formatted link to open player in-game. */
|
|
57
59
|
get shareLink(): string;
|
|
58
60
|
}
|
|
@@ -64,10 +66,12 @@ export declare class RankedClan {
|
|
|
64
66
|
tag: string;
|
|
65
67
|
/** The clan's level. */
|
|
66
68
|
level: number;
|
|
67
|
-
/** The clan's trophy count. If retrieving info for
|
|
69
|
+
/** The clan's trophy count. If retrieving info for builder base leader-boards, this will be `null`. */
|
|
68
70
|
points: number | null;
|
|
69
|
-
/** The clan's
|
|
70
|
-
|
|
71
|
+
/** The clan's builder base trophy count. If retrieving info for regular leader boards, this will be `null`. */
|
|
72
|
+
builderBasePoints: number | null;
|
|
73
|
+
/** @deprecated */
|
|
74
|
+
versusPoints?: number | null;
|
|
71
75
|
/** The clan's location. */
|
|
72
76
|
location: Location;
|
|
73
77
|
/** The number of members in the clan. */
|
|
@@ -78,7 +82,7 @@ export declare class RankedClan {
|
|
|
78
82
|
previousRank: number;
|
|
79
83
|
/** The clan's badge. */
|
|
80
84
|
badge: Badge;
|
|
81
|
-
constructor(data: APIClanRanking |
|
|
85
|
+
constructor(data: APIClanRanking | APIClanBuilderBaseRanking);
|
|
82
86
|
/** Get clan's formatted link to open clan in-game. */
|
|
83
87
|
get shareLink(): string;
|
|
84
88
|
}
|