clashofclans.js 2.0.1 → 2.0.2-dev.6e23d2f

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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## 2.0.2 (2021-11-30)
6
+
7
+ ### Bug Fixes
8
+
9
+ - Return `null` for `RankedPlayer.clan` if they are not in the clan. ([#73](https://github.com/clashperk/clashofclans.js/pull/73)) ([ba82327](https://github.com/clashperk/clashofclans.js/commit/ba8232740f4ca9af2bcc7971aca3574612ef25b6))
10
+ - `OverrideOptions` added for `Client#getClans` and `RESTManager#getClans` ([#73](https://github.com/clashperk/clashofclans.js/pull/73)) ([ba82327](https://github.com/clashperk/clashofclans.js/commit/ba8232740f4ca9af2bcc7971aca3574612ef25b6))
11
+ - `SeasonRankedPlayer` class for legend league ranking. ([#73](https://github.com/clashperk/clashofclans.js/pull/73)) ([ba82327](https://github.com/clashperk/clashofclans.js/commit/ba8232740f4ca9af2bcc7971aca3574612ef25b6))
12
+
5
13
  ## 2.0.1 (2021-11-27)
6
14
 
7
15
  ### Bug Fixes
@@ -21,14 +29,3 @@ This new version is a complete TypeScript rewrite to convert everything from pla
21
29
  - Override Request Options ([#36](https://github.com/clashperk/clashofclans.js/issues/36)) ([42d7fdd](https://github.com/clashperk/clashofclans.js/commit/42d7fdd36262cc46f23b731f8cffb9daea19d3b0))
22
30
  - Internal Caching Options ([#53](https://github.com/clashperk/clashofclans.js/issues/53)) ([984451d](https://github.com/clashperk/clashofclans.js/commit/30ea3240c11866008d0dae514468c0fdbb34ffd0))
23
31
  - Additional Properties for Player Units ([#65](https://github.com/clashperk/clashofclans.js/pull/65)) ([aa1696](https://github.com/clashperk/clashofclans.js/commit/aa1696243d96d4fed0250b4282c60522a6482343))
24
-
25
- ### Links
26
-
27
- - Documentation
28
- https://clashofclans.js.org/docs
29
-
30
- - Guide
31
- https://clashofclans.js.org/guide
32
-
33
- - Updating to v2.0.0
34
- https://clashofclans.js.org/docs/updating-to-v2
@@ -5,7 +5,7 @@ import { RESTManager } from '../rest/RESTManager';
5
5
  import { EventManager } from './EventManager';
6
6
  import { EventEmitter } from 'events';
7
7
  import { Util } from '../util/Util';
8
- import { Clan, ClanMember, ClanWar, ClanWarLog, League, Location, Player, WarLeague, RankedClan, RankedPlayer, Label, GoldPassSeason, ClanWarLeagueGroup } from '../struct';
8
+ import { Clan, ClanMember, ClanWar, ClanWarLog, League, Location, Player, WarLeague, RankedClan, RankedPlayer, Label, SeasonRankedPlayer, GoldPassSeason, ClanWarLeagueGroup } from '../struct';
9
9
  /**
10
10
  * Represents Clash of Clans API Client.
11
11
  * ```js
@@ -35,8 +35,8 @@ export declare class Client extends EventEmitter {
35
35
  /** Set Clash of Clans API keys. */
36
36
  setKeys(keys: string[]): this;
37
37
  /** Search all clans by name and/or filtering the results using various criteria. */
38
- getClans(options: ClanSearchOptions): Promise<Clan[]>;
39
- /** Get information about a clan. */
38
+ getClans(query: ClanSearchOptions, options?: OverrideOptions): Promise<Clan[]>;
39
+ /** Get info about a clan. */
40
40
  getClan(clanTag: string, options?: OverrideOptions): Promise<Clan>;
41
41
  /** Get list of clan members. */
42
42
  getClanMembers(clanTag: string, options?: SearchOptions): Promise<ClanMember[]>;
@@ -76,14 +76,14 @@ export declare class Client extends EventEmitter {
76
76
  }, options?: OverrideOptions): Promise<ClanWar | null>;
77
77
  private _getCurrentLeagueWars;
78
78
  private _getClanWars;
79
- /** Get information about clan war league. */
79
+ /** Get info about clan war league. */
80
80
  getClanWarLeagueGroup(clanTag: string, options?: OverrideOptions): Promise<ClanWarLeagueGroup>;
81
81
  /** Get info about a CWL round by WarTag. */
82
82
  getClanWarLeagueRound(warTag: string | {
83
83
  warTag: string;
84
84
  clanTag?: string;
85
85
  }, options?: OverrideOptions): Promise<ClanWar>;
86
- /** Get information about a player by tag. */
86
+ /** Get info about a player by tag. */
87
87
  getPlayer(playerTag: string, options?: OverrideOptions): Promise<Player>;
88
88
  /** Verify Player API token that can be found from the Game settings. */
89
89
  verifyPlayerToken(playerTag: string, token: string, options?: OverrideOptions): Promise<boolean>;
@@ -92,18 +92,34 @@ export declare class Client extends EventEmitter {
92
92
  /** Get Legend League season Ids. */
93
93
  getLeagueSeasons(options?: SearchOptions): Promise<string[]>;
94
94
  /** Get Legend League season rankings by season Id. */
95
- getSeasonRankings(seasonId: string, options?: SearchOptions): Promise<RankedPlayer[]>;
95
+ getSeasonRankings(seasonId: string, options?: SearchOptions): Promise<SeasonRankedPlayer[]>;
96
96
  /** Get list of Clan War Leagues. */
97
97
  getWarLeagues(options?: SearchOptions): Promise<WarLeague[]>;
98
98
  /** Get list of Locations. */
99
99
  getLocations(options?: SearchOptions): Promise<Location[]>;
100
- /** Get clan rankings for a specific location. */
100
+ /**
101
+ * Get clan rankings for a specific location.
102
+ *
103
+ * For global ranking, use `global` as `locationId`.
104
+ */
101
105
  getClanRanks(locationId: number | 'global', options?: SearchOptions): Promise<RankedClan[]>;
102
- /** Get player rankings for a specific location. */
106
+ /**
107
+ * Get player rankings for a specific location.
108
+ *
109
+ * For global ranking, use `global` as `locationId`.
110
+ */
103
111
  getPlayerRanks(locationId: number | 'global', options?: SearchOptions): Promise<RankedPlayer[]>;
104
- /** Get clan versus rankings for a specific location. */
112
+ /**
113
+ * Get clan versus rankings for a specific location.
114
+ *
115
+ * For global ranking, use `global` as `locationId`.
116
+ */
105
117
  getVersusClanRanks(locationId: number | 'global', options?: SearchOptions): Promise<RankedClan[]>;
106
- /** Get player versus rankings for a specific location. */
118
+ /**
119
+ * Get player versus rankings for a specific location.
120
+ *
121
+ * For global ranking, use `global` as `locationId`.
122
+ */
107
123
  getVersusPlayerRanks(locationId: number | 'global', options?: SearchOptions): Promise<RankedPlayer[]>;
108
124
  /** Get list of clan labels. */
109
125
  getClanLabels(options?: SearchOptions): Promise<Label[]>;
@@ -47,12 +47,12 @@ class Client extends events_1.EventEmitter {
47
47
  return this;
48
48
  }
49
49
  /** Search all clans by name and/or filtering the results using various criteria. */
50
- async getClans(options) {
51
- const { data } = await this.rest.getClans(options);
50
+ async getClans(query, options) {
51
+ const { data } = await this.rest.getClans(query, options);
52
52
  // @ts-expect-error
53
53
  return data.items.map((clan) => new struct_1.Clan(this, clan));
54
54
  }
55
- /** Get information about a clan. */
55
+ /** Get info about a clan. */
56
56
  async getClan(clanTag, options) {
57
57
  const { data } = await this.rest.getClan(clanTag, options);
58
58
  return new struct_1.Clan(this, data);
@@ -148,7 +148,7 @@ class Client extends events_1.EventEmitter {
148
148
  throw e;
149
149
  }
150
150
  }
151
- /** Get information about clan war league. */
151
+ /** Get info about clan war league. */
152
152
  async getClanWarLeagueGroup(clanTag, options) {
153
153
  const { data } = await this.rest.getClanWarLeagueGroup(clanTag, options);
154
154
  return new struct_1.ClanWarLeagueGroup(this, data);
@@ -162,7 +162,7 @@ class Client extends events_1.EventEmitter {
162
162
  }
163
163
  return new struct_1.ClanWar(this, data, { warTag: args.warTag, clanTag: args.clanTag, maxAge });
164
164
  }
165
- /** Get information about a player by tag. */
165
+ /** Get info about a player by tag. */
166
166
  async getPlayer(playerTag, options) {
167
167
  const { data } = await this.rest.getPlayer(playerTag, options);
168
168
  return new struct_1.Player(this, data);
@@ -185,8 +185,7 @@ class Client extends events_1.EventEmitter {
185
185
  /** Get Legend League season rankings by season Id. */
186
186
  async getSeasonRankings(seasonId, options) {
187
187
  const { data } = await this.rest.getSeasonRankings(Constants_1.LEGEND_LEAGUE_ID, seasonId, options);
188
- // @ts-expect-error
189
- return data.items.map((entry) => new struct_1.RankedPlayer(entry));
188
+ return data.items.map((entry) => new struct_1.SeasonRankedPlayer(this, entry));
190
189
  }
191
190
  /** Get list of Clan War Leagues. */
192
191
  async getWarLeagues(options) {
@@ -198,22 +197,38 @@ class Client extends events_1.EventEmitter {
198
197
  const { data } = await this.rest.getLocations(options);
199
198
  return data.items.map((entry) => new struct_1.Location(entry));
200
199
  }
201
- /** Get clan rankings for a specific location. */
200
+ /**
201
+ * Get clan rankings for a specific location.
202
+ *
203
+ * For global ranking, use `global` as `locationId`.
204
+ */
202
205
  async getClanRanks(locationId, options) {
203
206
  const { data } = await this.rest.getClanRanks(locationId, options);
204
207
  return data.items.map((entry) => new struct_1.RankedClan(entry));
205
208
  }
206
- /** Get player rankings for a specific location. */
209
+ /**
210
+ * Get player rankings for a specific location.
211
+ *
212
+ * For global ranking, use `global` as `locationId`.
213
+ */
207
214
  async getPlayerRanks(locationId, options) {
208
215
  const { data } = await this.rest.getPlayerRanks(locationId, options);
209
216
  return data.items.map((entry) => new struct_1.RankedPlayer(this, entry));
210
217
  }
211
- /** Get clan versus rankings for a specific location. */
218
+ /**
219
+ * Get clan versus rankings for a specific location.
220
+ *
221
+ * For global ranking, use `global` as `locationId`.
222
+ */
212
223
  async getVersusClanRanks(locationId, options) {
213
224
  const { data } = await this.rest.getVersusClanRanks(locationId, options);
214
225
  return data.items.map((entry) => new struct_1.RankedClan(entry));
215
226
  }
216
- /** Get player versus rankings for a specific location. */
227
+ /**
228
+ * Get player versus rankings for a specific location.
229
+ *
230
+ * For global ranking, use `global` as `locationId`.
231
+ */
217
232
  async getVersusPlayerRanks(locationId, options) {
218
233
  const { data } = await this.rest.getVersusPlayerRanks(locationId, options);
219
234
  return data.items.map((entry) => new struct_1.RankedPlayer(this, entry));
@@ -1,10 +1,15 @@
1
1
  /** Represents an HTTP Error. */
2
2
  export declare class HTTPError extends Error {
3
- /** The message of this error. */
3
+ /** The message of this errored request. */
4
4
  message: string;
5
5
  /** The HTTP method of this request. */
6
6
  method: string;
7
- /** The reason of this error. */
7
+ /**
8
+ * The reason of this errored request.
9
+ *
10
+ * Expected values are `notFound`, `notInWar`, `accessDenied`, `accessDenied.invalidIp`, `privateWarLog`,
11
+ * `badRequest`, `requestThrottled`, `serviceUnavailable`, `requestAborted` and `unknownException`.
12
+ */
8
13
  reason: string;
9
14
  /** The HTTP status code of this request. */
10
15
  status: number;
@@ -12,10 +12,10 @@ const messages = {
12
12
  };
13
13
  const reasons = {
14
14
  503: 'serviceUnavailable',
15
- 429: 'tooManyRequests',
15
+ 429: 'requestThrottled',
16
16
  400: 'badRequest',
17
- 403: 'forbidden',
18
- 500: 'unknownError',
17
+ 403: 'accessDenied',
18
+ 500: 'unknownException',
19
19
  404: 'notFound',
20
20
  504: 'requestAborted'
21
21
  };
@@ -6,8 +6,8 @@ export declare class RESTManager {
6
6
  readonly handler: RequestHandler;
7
7
  constructor(options?: ClientOptions);
8
8
  /** Search all clans by name and/or filtering the results using various criteria. */
9
- getClans(options: ClanSearchOptions): Promise<import("./RequestHandler").Response<APIClanList>>;
10
- /** Get information about a clan. */
9
+ getClans(query: ClanSearchOptions, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIClanList>>;
10
+ /** Get info about a clan. */
11
11
  getClan(clanTag: string, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIClan>>;
12
12
  /** Get list of clan members. */
13
13
  getClanMembers(clanTag: string, options?: SearchOptions): Promise<import("./RequestHandler").Response<APIClanMemberList>>;
@@ -15,11 +15,11 @@ export declare class RESTManager {
15
15
  getClanWarLog(clanTag: string, options?: SearchOptions): Promise<import("./RequestHandler").Response<APIClanWarLog>>;
16
16
  /** Get info about currently running war in the clan. */
17
17
  getCurrentWar(clanTag: string, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIClanWar>>;
18
- /** Get information about clan war league. */
18
+ /** Get info about clan war league. */
19
19
  getClanWarLeagueGroup(clanTag: string, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIClanWarLeagueGroup>>;
20
20
  /** Get info about a CWL round by WarTag. */
21
21
  getClanWarLeagueRound(warTag: string, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIClanWar>>;
22
- /** Get information about a player by tag. */
22
+ /** Get info about a player by tag. */
23
23
  getPlayer(playerTag: string, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIPlayer>>;
24
24
  /** Verify Player API token that can be found from the Game settings. */
25
25
  verifyPlayerToken(playerTag: string, token: string, options?: OverrideOptions): Promise<import("./RequestHandler").Response<APIVerifyToken>>;
@@ -9,11 +9,10 @@ class RESTManager {
9
9
  this.handler = new RequestHandler_1.RequestHandler(options);
10
10
  }
11
11
  /** Search all clans by name and/or filtering the results using various criteria. */
12
- getClans(options) {
13
- const query = Util_1.Util.queryString(options);
14
- return this.handler.request(`/clans?${query}`);
12
+ getClans(query, options) {
13
+ return this.handler.request(`/clans?${Util_1.Util.queryString(query)}`, options);
15
14
  }
16
- /** Get information about a clan. */
15
+ /** Get info about a clan. */
17
16
  getClan(clanTag, options) {
18
17
  return this.handler.request(`/clans/${Util_1.Util.encodeTag(clanTag)}`, options);
19
18
  }
@@ -31,7 +30,7 @@ class RESTManager {
31
30
  getCurrentWar(clanTag, options) {
32
31
  return this.handler.request(`/clans/${Util_1.Util.encodeTag(clanTag)}/currentwar`, options);
33
32
  }
34
- /** Get information about clan war league. */
33
+ /** Get info about clan war league. */
35
34
  getClanWarLeagueGroup(clanTag, options) {
36
35
  return this.handler.request(`/clans/${Util_1.Util.encodeTag(clanTag)}/currentwar/leaguegroup`, options);
37
36
  }
@@ -39,7 +38,7 @@ class RESTManager {
39
38
  getClanWarLeagueRound(warTag, options) {
40
39
  return this.handler.request(`/clanwarleagues/wars/${Util_1.Util.encodeTag(warTag)}`, options);
41
40
  }
42
- /** Get information about a player by tag. */
41
+ /** Get info about a player by tag. */
43
42
  getPlayer(playerTag, options) {
44
43
  return this.handler.request(`/players/${Util_1.Util.encodeTag(playerTag)}`, options);
45
44
  }
@@ -59,6 +59,6 @@ export declare class Clan {
59
59
  */
60
60
  members: ClanMember[];
61
61
  constructor(client: Client, data: APIClan);
62
- /** Get {@link Player} information for every Player in the clan. */
62
+ /** Get {@link Player} info for every Player in the clan. */
63
63
  fetchMembers(options?: OverrideOptions): Promise<Player[]>;
64
64
  }
@@ -34,7 +34,7 @@ class Clan {
34
34
  this.labels = data.labels.map((label) => new Label_1.Label(label));
35
35
  this.members = data.memberList?.map((mem) => new ClanMember_1.ClanMember(this.client, mem)) ?? []; // eslint-disable-line
36
36
  }
37
- /** Get {@link Player} information for every Player in the clan. */
37
+ /** Get {@link Player} info for every Player in the clan. */
38
38
  async fetchMembers(options) {
39
39
  return (await Promise.allSettled(this.members.map((m) => this.client.getPlayer(m.tag, { ...options, ignoreRateLimit: true }))))
40
40
  .filter((res) => res.status === 'fulfilled')
@@ -134,7 +134,7 @@ class ClanWar {
134
134
  // @ts-expect-error
135
135
  this.state = data.state;
136
136
  this.teamSize = data.teamSize;
137
- this.attacksPerMember = data.attacksPerMember;
137
+ this.attacksPerMember = data.attacksPerMember ?? extra.warTag ? 1 : 2;
138
138
  this.preparationStartTime = client.util.parseDate(data.preparationStartTime);
139
139
  this.startTime = client.util.parseDate(data.startTime);
140
140
  this.endTime = client.util.parseDate(data.endTime);
@@ -28,7 +28,7 @@ export declare class ClanWarLeagueClan {
28
28
  /** An array of members that are in the CWL group. */
29
29
  members: ClanWarLeagueClanMember[];
30
30
  constructor(client: Client, data: APIClanWarLeagueClan);
31
- /** Get {@link Player} information for every members that are in the CWL group. */
31
+ /** Get {@link Player} info for every members that are in the CWL group. */
32
32
  fetchMembers(options?: OverrideOptions): Promise<Player[]>;
33
33
  }
34
34
  /** Represents a Round of CWL Group. */
@@ -21,7 +21,7 @@ class ClanWarLeagueClan {
21
21
  this.badge = new Badge_1.Badge(data.badgeUrls);
22
22
  this.members = data.members.map((mem) => new ClanWarLeagueClanMember(mem));
23
23
  }
24
- /** Get {@link Player} information for every members that are in the CWL group. */
24
+ /** Get {@link Player} info for every members that are in the CWL group. */
25
25
  async fetchMembers(options) {
26
26
  return (await Promise.allSettled(this.members.map((m) => this.client.getPlayer(m.tag, { ...options, ignoreRateLimit: true }))))
27
27
  .filter((res) => res.status === 'fulfilled')
@@ -2,15 +2,19 @@ import { OverrideOptions } from '../rest/RequestHandler';
2
2
  import { Client } from '../client/Client';
3
3
  import { APIPlayerClan } from '../types';
4
4
  import { Badge } from './Badge';
5
- /** Represents a player's clan. */
5
+ /** Represents a Player's clan. */
6
6
  export declare class PlayerClan {
7
7
  private readonly _client;
8
8
  /** Name of the clan. */
9
9
  name: string;
10
10
  /** Tag of the clan. */
11
11
  tag: string;
12
- /** Level of this clan. */
13
- level: number;
12
+ /**
13
+ * Level of this clan.
14
+ *
15
+ * This property is not available for ranked player's clan.
16
+ */
17
+ level: number | null;
14
18
  /** Badge of this clan. */
15
19
  badge: Badge;
16
20
  constructor(_client: Client, data: APIPlayerClan);
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PlayerClan = void 0;
4
4
  const Badge_1 = require("./Badge");
5
- /** Represents a player's clan. */
5
+ /** Represents a Player's clan. */
6
6
  class PlayerClan {
7
7
  constructor(_client, data) {
8
8
  this._client = _client;
9
9
  this.name = data.name;
10
10
  this.tag = data.tag;
11
- this.level = data.clanLevel;
11
+ this.level = data.clanLevel ?? null; // eslint-disable-line
12
12
  this.badge = new Badge_1.Badge(data.badgeUrls);
13
13
  }
14
14
  /** Fetch detailed clan info for the player's clan. */
@@ -4,7 +4,27 @@ import { Client } from '../client/Client';
4
4
  import { Location } from './Location';
5
5
  import { League } from './League';
6
6
  import { Badge } from './Badge';
7
- /** Represents the player of leader-board ranking. */
7
+ /** Represents the Player of seasonal legend league leader-board ranking. */
8
+ export declare class SeasonRankedPlayer {
9
+ /** The player's name. */
10
+ name: string;
11
+ /** The player's tag. */
12
+ tag: string;
13
+ /** The player's experience level. */
14
+ expLevel: number;
15
+ /** The player's trophy count. */
16
+ trophies: number;
17
+ /** The player's attack wins. */
18
+ attackWins: number;
19
+ /** The player's defense wins. */
20
+ defenseWins: number;
21
+ /** The player's rank in the clan leader-board. */
22
+ rank: number;
23
+ /** The player's clan. */
24
+ clan: PlayerClan | null;
25
+ constructor(client: Client, data: Omit<APIPlayerRanking, 'league'>);
26
+ }
27
+ /** Represents the Player of location based leader-board ranking. */
8
28
  export declare class RankedPlayer {
9
29
  /** The player's name. */
10
30
  name: string;
@@ -24,15 +44,15 @@ export declare class RankedPlayer {
24
44
  versusBattleWins: number | null;
25
45
  /** The player's rank in the clan leader-board. */
26
46
  rank: number;
27
- /** The player's rank before the last leader-board change. */
28
- previousRank: number;
47
+ /** The player's rank before the last leader-board change. If retrieving info for legend league season, this will be `null`. */
48
+ previousRank: number | null;
29
49
  /** The player's clan. */
30
- clan: PlayerClan;
50
+ clan: PlayerClan | null;
31
51
  /** The player's league. If retrieving info for versus leader-boards, this will be `null`. */
32
52
  league: League | null;
33
53
  constructor(client: Client, data: APIPlayerRanking | APIPlayerVersusRanking);
34
54
  }
35
- /** Represents the clan of leader-board ranking. */
55
+ /** Represents the Clan of location based leader-board ranking. */
36
56
  export declare class RankedClan {
37
57
  /** The clan's name. */
38
58
  name: string;
@@ -1,12 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RankedClan = exports.RankedPlayer = void 0;
3
+ exports.RankedClan = exports.RankedPlayer = exports.SeasonRankedPlayer = void 0;
4
4
  const Constants_1 = require("../util/Constants");
5
5
  const PlayerClan_1 = require("./PlayerClan");
6
6
  const Location_1 = require("./Location");
7
7
  const League_1 = require("./League");
8
8
  const Badge_1 = require("./Badge");
9
- /** Represents the player of leader-board ranking. */
9
+ /** Represents the Player of seasonal legend league leader-board ranking. */
10
+ class SeasonRankedPlayer {
11
+ constructor(client, data) {
12
+ this.name = data.name;
13
+ this.tag = data.tag;
14
+ this.rank = data.rank;
15
+ this.expLevel = data.expLevel;
16
+ this.trophies = data.trophies;
17
+ this.attackWins = data.attackWins;
18
+ this.defenseWins = data.defenseWins;
19
+ // @ts-expect-error
20
+ this.clan = data.clan ? new PlayerClan_1.PlayerClan(client, data.clan) : null;
21
+ }
22
+ }
23
+ exports.SeasonRankedPlayer = SeasonRankedPlayer;
24
+ /** Represents the Player of location based leader-board ranking. */
10
25
  class RankedPlayer {
11
26
  constructor(client, data) {
12
27
  this.name = data.name;
@@ -23,14 +38,15 @@ class RankedPlayer {
23
38
  // @ts-expect-error
24
39
  this.versusBattleWins = data.versusBattleWins ?? null;
25
40
  this.rank = data.rank;
26
- this.previousRank = data.previousRank;
27
- this.clan = new PlayerClan_1.PlayerClan(client, data.clan);
41
+ this.previousRank = data.previousRank ?? null; // eslint-disable-line
42
+ // @ts-expect-error
43
+ this.clan = data.clan ? new PlayerClan_1.PlayerClan(client, data.clan) : null;
28
44
  // @ts-expect-error
29
45
  this.league = data.trophies ? new League_1.League(data.league ?? Constants_1.UNRANKED_LEAGUE_DATA) : null; // eslint-disable-line
30
46
  }
31
47
  }
32
48
  exports.RankedPlayer = RankedPlayer;
33
- /** Represents the clan of leader-board ranking. */
49
+ /** Represents the Clan of location based leader-board ranking. */
34
50
  class RankedClan {
35
51
  constructor(data) {
36
52
  this.name = data.name;
@@ -84,7 +84,8 @@ export interface APIClanWar {
84
84
  endTime: string;
85
85
  clan: APIWarClan;
86
86
  opponent: APIWarClan;
87
- attacksPerMember: number;
87
+ /** This property is not available for CWL */
88
+ attacksPerMember?: number;
88
89
  }
89
90
  export interface APIWarClan {
90
91
  tag: string;
@@ -266,7 +267,7 @@ export interface APIPlayerRanking {
266
267
  defenseWins: number;
267
268
  rank: number;
268
269
  previousRank: number;
269
- clan: APIPlayerClan;
270
+ clan?: Omit<APIPlayerClan, 'clanLevel'>;
270
271
  league: APILeague;
271
272
  }
272
273
  /** /locations/{locationId}/rankings/clans-versus */
@@ -298,7 +299,7 @@ export interface APIPlayerVersusRanking {
298
299
  versusBattleWins: number;
299
300
  rank: number;
300
301
  previousRank: number;
301
- clan: APIPlayerClan;
302
+ clan?: APIPlayerClan;
302
303
  }
303
304
  /** /leagues */
304
305
  export interface APILeagueList {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clashofclans.js",
3
- "version": "2.0.1",
3
+ "version": "2.0.2-dev.6e23d2f",
4
4
  "description": "JavaScript library for interacting with the Clash of Clans API",
5
5
  "author": "SUVAJIT <suvajit.me@gmail.com>",
6
6
  "license": "MIT",
@@ -12,6 +12,9 @@
12
12
  "test": "eslint --ext .ts --ignore-path .gitignore .",
13
13
  "lint": "eslint --fix --ext .ts --ignore-path .gitignore ."
14
14
  },
15
+ "files": [
16
+ "dist"
17
+ ],
15
18
  "repository": {
16
19
  "type": "git",
17
20
  "url": "https://github.com/clashperk/clashofclans.js.git"