clashofclans.js 2.6.1 → 2.7.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/CHANGELOG.md CHANGED
@@ -2,9 +2,15 @@
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.6.1 (2022-02-03)
5
+ ## 2.7.0 (2022-05-22)
6
6
 
7
- Bug Fixes
7
+ ### Features
8
+
9
+ - Some useful QOL methods have been added. ([#106](https://github.com/clashperk/clashofclans.js/pull/106))
10
+
11
+ ## 2.6.1 (2022-02-03)
12
+
13
+ ### Bug Fixes
8
14
 
9
15
  - New value and typings `notInWar` added for `ClanWarLeagueGroup#state` ([#101](https://github.com/clashperk/clashofclans.js/pull/101))
10
16
  - Throw error if `Util.formatTag` / `Util.parseTag` is called with invalid argument ([#102](https://github.com/clashperk/clashofclans.js/pull/101))
@@ -34,8 +34,8 @@ export declare class Client extends EventEmitter {
34
34
  login(options: LoginOptions): Promise<string[]>;
35
35
  /** Set Clash of Clans API keys. */
36
36
  setKeys(keys: string[]): this;
37
- /** Search all clans by name and/or filtering the results using various criteria. */
38
- getClans(query: ClanSearchOptions, options?: OverrideOptions): Promise<Clan[]>;
37
+ /** Search clans by name and/or filtering parameters or get clans by their tags (fetches in parallel). */
38
+ getClans(query: ClanSearchOptions | string[], options?: OverrideOptions): Promise<Clan[]>;
39
39
  /** Get info about a clan. */
40
40
  getClan(clanTag: string, options?: OverrideOptions): Promise<Clan>;
41
41
  /** Get list of clan members. */
@@ -85,6 +85,8 @@ export declare class Client extends EventEmitter {
85
85
  }, options?: OverrideOptions): Promise<ClanWar>;
86
86
  /** Get info about a player by tag. */
87
87
  getPlayer(playerTag: string, options?: OverrideOptions): Promise<Player>;
88
+ /** Get info about some players by their tags (fetches in parallel). */
89
+ getPlayers(playerTags: string[], options?: OverrideOptions): Promise<Player[]>;
88
90
  /** Verify Player API token that can be found from the Game settings. */
89
91
  verifyPlayerToken(playerTag: string, token: string, options?: OverrideOptions): Promise<boolean>;
90
92
  /** Get list of Leagues. */
@@ -46,8 +46,13 @@ class Client extends events_1.EventEmitter {
46
46
  this.rest.handler.setKeys(keys);
47
47
  return this;
48
48
  }
49
- /** Search all clans by name and/or filtering the results using various criteria. */
49
+ /** Search clans by name and/or filtering parameters or get clans by their tags (fetches in parallel). */
50
50
  async getClans(query, options) {
51
+ if (Array.isArray(query)) {
52
+ return (await Promise.allSettled(query.map((tag) => this.getClan(tag, options))))
53
+ .filter((res) => res.status === 'fulfilled')
54
+ .map((res) => res.value);
55
+ }
51
56
  const { data } = await this.rest.getClans(query, options);
52
57
  // @ts-expect-error
53
58
  return data.items.map((clan) => new struct_1.Clan(this, clan));
@@ -170,6 +175,12 @@ class Client extends events_1.EventEmitter {
170
175
  const { data } = await this.rest.getPlayer(playerTag, options);
171
176
  return new struct_1.Player(this, data);
172
177
  }
178
+ /** Get info about some players by their tags (fetches in parallel). */
179
+ async getPlayers(playerTags, options) {
180
+ return (await Promise.allSettled(playerTags.map((tag) => this.getPlayer(tag, options))))
181
+ .filter((res) => res.status === 'fulfilled')
182
+ .map((res) => res.value);
183
+ }
173
184
  /** Verify Player API token that can be found from the Game settings. */
174
185
  async verifyPlayerToken(playerTag, token, options) {
175
186
  const { data } = await this.rest.verifyPlayerToken(playerTag, token, options);
package/dist/index.mjs ADDED
@@ -0,0 +1,66 @@
1
+ import mod from "./index.js";
2
+
3
+ export default mod;
4
+ export const API_BASE_URL = mod.API_BASE_URL;
5
+ export const Achievement = mod.Achievement;
6
+ export const BUILDER_TROOPS = mod.BUILDER_TROOPS;
7
+ export const Badge = mod.Badge;
8
+ export const BatchThrottler = mod.BatchThrottler;
9
+ export const CWL_ROUNDS = mod.CWL_ROUNDS;
10
+ export const CacheStore = mod.CacheStore;
11
+ export const ChatLanguage = mod.ChatLanguage;
12
+ export const Clan = mod.Clan;
13
+ export const ClanMember = mod.ClanMember;
14
+ export const ClanWar = mod.ClanWar;
15
+ export const ClanWarAttack = mod.ClanWarAttack;
16
+ export const ClanWarLeagueClan = mod.ClanWarLeagueClan;
17
+ export const ClanWarLeagueClanMember = mod.ClanWarLeagueClanMember;
18
+ export const ClanWarLeagueGroup = mod.ClanWarLeagueGroup;
19
+ export const ClanWarLeagueRound = mod.ClanWarLeagueRound;
20
+ export const ClanWarLog = mod.ClanWarLog;
21
+ export const ClanWarMember = mod.ClanWarMember;
22
+ export const Client = mod.Client;
23
+ export const DARK_ELIXIR_SPELLS = mod.DARK_ELIXIR_SPELLS;
24
+ export const DARK_ELIXIR_TROOPS = mod.DARK_ELIXIR_TROOPS;
25
+ export const DEV_SITE_API_BASE_URL = mod.DEV_SITE_API_BASE_URL;
26
+ export const ELIXIR_SPELLS = mod.ELIXIR_SPELLS;
27
+ export const ELIXIR_TROOPS = mod.ELIXIR_TROOPS;
28
+ export const EVENTS = mod.EVENTS;
29
+ export const EventManager = mod.EventManager;
30
+ export const FRIENDLY_WAR_PREPARATION_TIMES = mod.FRIENDLY_WAR_PREPARATION_TIMES;
31
+ export const GoldPassSeason = mod.GoldPassSeason;
32
+ export const HEROES = mod.HEROES;
33
+ export const HERO_PETS = mod.HERO_PETS;
34
+ export const HOME_TROOPS = mod.HOME_TROOPS;
35
+ export const HTTPError = mod.HTTPError;
36
+ export const Hero = mod.Hero;
37
+ export const Icon = mod.Icon;
38
+ export const LEAGUES = mod.LEAGUES;
39
+ export const LEGEND_LEAGUE_ID = mod.LEGEND_LEAGUE_ID;
40
+ export const Label = mod.Label;
41
+ export const League = mod.League;
42
+ export const LegendStatistics = mod.LegendStatistics;
43
+ export const Location = mod.Location;
44
+ export const NotInWarError = mod.NotInWarError;
45
+ export const Player = mod.Player;
46
+ export const PlayerClan = mod.PlayerClan;
47
+ export const PrivateWarLogError = mod.PrivateWarLogError;
48
+ export const QueueThrottler = mod.QueueThrottler;
49
+ export const RESTManager = mod.RESTManager;
50
+ export const RankedClan = mod.RankedClan;
51
+ export const RankedPlayer = mod.RankedPlayer;
52
+ export const RequestHandler = mod.RequestHandler;
53
+ export const SIEGE_MACHINES = mod.SIEGE_MACHINES;
54
+ export const SPELLS = mod.SPELLS;
55
+ export const SUPER_TROOPS = mod.SUPER_TROOPS;
56
+ export const Season = mod.Season;
57
+ export const SeasonRankedPlayer = mod.SeasonRankedPlayer;
58
+ export const Spell = mod.Spell;
59
+ export const Troop = mod.Troop;
60
+ export const UNRANKED_LEAGUE_DATA = mod.UNRANKED_LEAGUE_DATA;
61
+ export const Unit = mod.Unit;
62
+ export const Util = mod.Util;
63
+ export const WAR_LEAGUES = mod.WAR_LEAGUES;
64
+ export const WarClan = mod.WarClan;
65
+ export const WarLeague = mod.WarLeague;
66
+ export const WarLogClan = mod.WarLogClan;
@@ -32,6 +32,8 @@ export declare class Clan {
32
32
  versusPoints: number;
33
33
  /** The minimum trophies required to apply to this clan. */
34
34
  requiredTrophies: number;
35
+ /** The minimum versus trophies required to apply to this clan. */
36
+ requiredVersusTrophies: number | null;
35
37
  /** The minimum hall level required to apply to this clan. */
36
38
  requiredTownHallLevel: number | null;
37
39
  /** The frequency for when this clan goes to war. */
@@ -60,4 +62,6 @@ export declare class Clan {
60
62
  constructor(client: Client, data: APIClan);
61
63
  /** Get {@link Player} info for every Player in the clan. */
62
64
  fetchMembers(options?: OverrideOptions): Promise<Player[]>;
65
+ /** Get clan's formatted link to open clan in-game. */
66
+ get shareLink(): string;
63
67
  }
@@ -23,6 +23,7 @@ class Clan {
23
23
  this.versusPoints = data.clanVersusPoints;
24
24
  this.requiredTrophies = data.requiredTrophies;
25
25
  this.requiredTownHallLevel = data.requiredTownhallLevel ?? null;
26
+ this.requiredVersusTrophies = data.requiredVersusTrophies ?? null;
26
27
  this.warFrequency = data.warFrequency;
27
28
  this.warWinStreak = data.warWinStreak;
28
29
  this.warWins = data.warWins;
@@ -40,5 +41,9 @@ class Clan {
40
41
  .filter((res) => res.status === 'fulfilled')
41
42
  .map((res) => res.value);
42
43
  }
44
+ /** Get clan's formatted link to open clan in-game. */
45
+ get shareLink() {
46
+ return `https://link.clashofclans.com/en?action=OpenClanProfile&tag=${this.tag.replace(/#/g, '')}`;
47
+ }
43
48
  }
44
49
  exports.Clan = Clan;
@@ -26,6 +26,14 @@ export declare class ClanMember {
26
26
  /** The member's donation received count for this season. */
27
27
  received: number;
28
28
  constructor(client: Client, data: APIClanMember);
29
+ /** Whether this clan member is in the clan. */
30
+ get isMember(): boolean;
31
+ /** Whether this clan member is an Elder. */
32
+ get isElder(): boolean;
33
+ /** Whether this clan member is a Co-Leader. */
34
+ get isCoLeader(): boolean;
35
+ /** Whether this clan member is a Leader. */
36
+ get isLeader(): boolean;
29
37
  /** Fetch detailed clan info for the member's clan. */
30
38
  fetch(options?: OverrideOptions): Promise<import("./Player").Player>;
31
39
  }
@@ -20,6 +20,22 @@ class ClanMember {
20
20
  this.donations = data.donations;
21
21
  this.received = data.donationsReceived;
22
22
  }
23
+ /** Whether this clan member is in the clan. */
24
+ get isMember() {
25
+ return this.role === 'member';
26
+ }
27
+ /** Whether this clan member is an Elder. */
28
+ get isElder() {
29
+ return this.role === 'elder';
30
+ }
31
+ /** Whether this clan member is a Co-Leader. */
32
+ get isCoLeader() {
33
+ return this.role === 'coLeader';
34
+ }
35
+ /** Whether this clan member is a Leader. */
36
+ get isLeader() {
37
+ return this.role === 'leader';
38
+ }
23
39
  /** Fetch detailed clan info for the member's clan. */
24
40
  async fetch(options) {
25
41
  return this.client.getPlayer(this.tag, options);
@@ -58,6 +58,8 @@ export declare class ClanWarMember {
58
58
  get defenses(): ClanWarAttack[];
59
59
  /** Best opponent attack on this base. */
60
60
  get bestOpponentAttack(): ClanWarAttack | null;
61
+ /** Get member's formatted link to open member in-game. */
62
+ get shareLink(): string;
61
63
  /**
62
64
  * Returns the previous best opponent attack on this village.
63
65
  * This is useful for calculating the new stars or destruction for new attacks.
@@ -96,6 +98,8 @@ export declare class WarClan {
96
98
  get defenses(): ClanWarAttack[];
97
99
  /** Get a member of the clan for the given tag, or `null` if not found. */
98
100
  getMember(tag: string): ClanWarMember | null;
101
+ /** Get clan's formatted link to open clan in-game. */
102
+ get shareLink(): string;
99
103
  }
100
104
  /** Represents a Clan War in Clash of Clans. */
101
105
  export declare class ClanWar {
@@ -131,12 +135,20 @@ export declare class ClanWar {
131
135
  getAttack(attackerTag: string, defenderTag: string): ClanWarAttack | null;
132
136
  /** Return a list of {@link ClanWarAttack} for the defenderTag provided. */
133
137
  getDefenses(defenderTag: string): ClanWarAttack[];
138
+ /** Whether this is a Battle Day. */
139
+ get isBattleDay(): boolean;
140
+ /** Whether this is a Preparation Day. */
141
+ get isPreparationDay(): boolean;
142
+ /** Whether this War has Ended. */
143
+ get isWarEnded(): boolean;
134
144
  /** Returns either `friendly`, `cwl` or `normal`. */
135
145
  get type(): "friendly" | "cwl" | "normal";
136
146
  /** Whether this is a friendly war. */
137
147
  get isFriendly(): boolean;
138
148
  /** Whether this is a CWL. */
139
149
  get isCWL(): boolean;
150
+ /** Whether this is a normal war. */
151
+ get isNormal(): boolean;
140
152
  /** Returns the war status, based off the home clan. */
141
153
  get status(): "win" | "lose" | "tie" | "pending";
142
154
  /** Returns the Clan War League Group. */
@@ -72,6 +72,10 @@ class ClanWarMember {
72
72
  return null;
73
73
  return this.war.getAttack(this._bestOpponentAttackerTag, this.tag);
74
74
  }
75
+ /** Get member's formatted link to open member in-game. */
76
+ get shareLink() {
77
+ return `https://link.clashofclans.com/en?action=OpenPlayerProfile&tag=${this.tag.replace(/#/g, '')}`;
78
+ }
75
79
  /**
76
80
  * Returns the previous best opponent attack on this village.
77
81
  * This is useful for calculating the new stars or destruction for new attacks.
@@ -127,6 +131,10 @@ class WarClan {
127
131
  getMember(tag) {
128
132
  return this.members.find((m) => m.tag === tag) ?? null;
129
133
  }
134
+ /** Get clan's formatted link to open clan in-game. */
135
+ get shareLink() {
136
+ return `https://link.clashofclans.com/en?action=OpenClanProfile&tag=${this.tag.replace(/#/g, '')}`;
137
+ }
130
138
  }
131
139
  exports.WarClan = WarClan;
132
140
  /** Represents a Clan War in Clash of Clans. */
@@ -170,6 +178,18 @@ class ClanWar {
170
178
  }
171
179
  return this.opponent.attacks.filter((atk) => atk.defenderTag === defenderTag);
172
180
  }
181
+ /** Whether this is a Battle Day. */
182
+ get isBattleDay() {
183
+ return this.state === 'inWar';
184
+ }
185
+ /** Whether this is a Preparation Day. */
186
+ get isPreparationDay() {
187
+ return this.state === 'preparation';
188
+ }
189
+ /** Whether this War has Ended. */
190
+ get isWarEnded() {
191
+ return this.state === 'warEnded';
192
+ }
173
193
  /** Returns either `friendly`, `cwl` or `normal`. */
174
194
  get type() {
175
195
  if (this.isFriendly)
@@ -187,6 +207,10 @@ class ClanWar {
187
207
  get isCWL() {
188
208
  return typeof this.warTag === 'string';
189
209
  }
210
+ /** Whether this is a normal war. */
211
+ get isNormal() {
212
+ return !this.isCWL && !this.isFriendly;
213
+ }
190
214
  /** Returns the war status, based off the home clan. */
191
215
  get status() {
192
216
  if (this.state === 'preparation')
@@ -12,6 +12,8 @@ export declare class ClanWarLeagueClanMember {
12
12
  /** The member's town hall level. */
13
13
  townHallLevel: number;
14
14
  constructor(data: APIClanWarLeagueClanMember);
15
+ /** Get member's formatted link to open member in-game. */
16
+ get shareLink(): string;
15
17
  }
16
18
  /** Represents a Clan of CWL Group. */
17
19
  export declare class ClanWarLeagueClan {
@@ -29,6 +31,8 @@ export declare class ClanWarLeagueClan {
29
31
  constructor(client: Client, data: APIClanWarLeagueClan);
30
32
  /** Get {@link Player} info for every members that are in the CWL group. */
31
33
  fetchMembers(options?: OverrideOptions): Promise<Player[]>;
34
+ /** Get clan's formatted link to open clan in-game. */
35
+ get shareLink(): string;
32
36
  }
33
37
  /** Represents a Round of CWL Group. */
34
38
  export declare class ClanWarLeagueRound {
@@ -50,6 +54,8 @@ export declare class ClanWarLeagueGroup {
50
54
  /** An array containing all war tags for each round. */
51
55
  rounds: ClanWarLeagueRound[];
52
56
  constructor(client: Client, data: APIClanWarLeagueGroup);
57
+ /** Total number of rounds for this CWL. */
58
+ get totalRounds(): number;
53
59
  /**
54
60
  * This returns an array of {@link ClanWar} which fetches all wars in parallel.
55
61
  * @param clanTag Optional clan tag. If present, this will only return wars which belong to this clan.
@@ -9,6 +9,10 @@ class ClanWarLeagueClanMember {
9
9
  this.tag = data.tag;
10
10
  this.townHallLevel = data.townHallLevel;
11
11
  }
12
+ /** Get member's formatted link to open member in-game. */
13
+ get shareLink() {
14
+ return `https://link.clashofclans.com/en?action=OpenPlayerProfile&tag=${this.tag.replace(/#/g, '')}`;
15
+ }
12
16
  }
13
17
  exports.ClanWarLeagueClanMember = ClanWarLeagueClanMember;
14
18
  /** Represents a Clan of CWL Group. */
@@ -27,6 +31,10 @@ class ClanWarLeagueClan {
27
31
  .filter((res) => res.status === 'fulfilled')
28
32
  .map((res) => res.value);
29
33
  }
34
+ /** Get clan's formatted link to open clan in-game. */
35
+ get shareLink() {
36
+ return `https://link.clashofclans.com/en?action=OpenClanProfile&tag=${this.tag.replace(/#/g, '')}`;
37
+ }
30
38
  }
31
39
  exports.ClanWarLeagueClan = ClanWarLeagueClan;
32
40
  /** Represents a Round of CWL Group. */
@@ -47,6 +55,10 @@ class ClanWarLeagueGroup {
47
55
  this.clans = data.clans.map((clan) => new ClanWarLeagueClan(client, clan));
48
56
  this.rounds = data.rounds.map((round, i) => new ClanWarLeagueRound(round, i));
49
57
  }
58
+ /** Total number of rounds for this CWL. */
59
+ get totalRounds() {
60
+ return this.clans.length - 1;
61
+ }
50
62
  /**
51
63
  * This returns an array of {@link ClanWar} which fetches all wars in parallel.
52
64
  * @param clanTag Optional clan tag. If present, this will only return wars which belong to this clan.
@@ -31,6 +31,8 @@ export declare class WarLogClan {
31
31
  */
32
32
  attackCount: number | null;
33
33
  constructor(data: APIWarLogClan);
34
+ /** Get clan's formatted link to open clan in-game. */
35
+ get shareLink(): string | null;
34
36
  }
35
37
  export declare class ClanWarLog {
36
38
  client: Client;
@@ -49,4 +51,10 @@ export declare class ClanWarLog {
49
51
  constructor(client: Client, data: APIClanWarLogEntry);
50
52
  /** Returns either `friendly`, `cwl` or `normal`. */
51
53
  get type(): "friendly" | "cwl" | "normal";
54
+ /** Whether this is a friendly war. */
55
+ get isFriendly(): boolean;
56
+ /** Whether this is a CWL. */
57
+ get isCWL(): boolean;
58
+ /** Whether this is a normal war. */
59
+ get isNormal(): boolean;
52
60
  }
@@ -20,6 +20,10 @@ class WarLogClan {
20
20
  this.destruction = data.destructionPercentage;
21
21
  this.expEarned = data.expEarned ?? null;
22
22
  }
23
+ /** Get clan's formatted link to open clan in-game. */
24
+ get shareLink() {
25
+ return this.tag ? `https://link.clashofclans.com/en?action=OpenClanProfile&tag=${this.tag.replace(/#/g, '')}` : null;
26
+ }
23
27
  }
24
28
  exports.WarLogClan = WarLogClan;
25
29
  class ClanWarLog {
@@ -40,5 +44,17 @@ class ClanWarLog {
40
44
  return 'cwl';
41
45
  return 'normal';
42
46
  }
47
+ /** Whether this is a friendly war. */
48
+ get isFriendly() {
49
+ return this.type === 'friendly';
50
+ }
51
+ /** Whether this is a CWL. */
52
+ get isCWL() {
53
+ return this.type === 'cwl';
54
+ }
55
+ /** Whether this is a normal war. */
56
+ get isNormal() {
57
+ return this.type === 'normal';
58
+ }
43
59
  }
44
60
  exports.ClanWarLog = ClanWarLog;
@@ -62,6 +62,16 @@ export declare class Player {
62
62
  /** An array of player's heroes (both home base and build base). */
63
63
  heroes: Hero[];
64
64
  constructor(client: Client, data: APIPlayer);
65
+ /** Whether this clan member is in the clan. */
66
+ get inClan(): boolean;
67
+ /** Whether this clan member is in the clan. */
68
+ get isMember(): boolean | null;
69
+ /** Whether this clan member is a Leader. */
70
+ get isLeader(): boolean | null;
71
+ /** Whether this clan member is a Co-Leader. */
72
+ get isCoLeader(): boolean | null;
73
+ /** Whether this clan member is an Elder. */
74
+ get isElder(): boolean | null;
65
75
  /** Fetch detailed clan info for the player's clan. */
66
76
  fetchClan(options?: OverrideOptions): Promise<import("./Clan").Clan | null>;
67
77
  /** An array of the player's home base troops. */
@@ -74,4 +84,6 @@ export declare class Player {
74
84
  get heroPets(): Troop[];
75
85
  /** An array of the player's siege machines. */
76
86
  get siegeMachines(): Troop[];
87
+ /** Get player's formatted link to open player in-game. */
88
+ get shareLink(): string;
77
89
  }
@@ -40,6 +40,26 @@ class Player {
40
40
  this.spells = data.spells.map((unit) => new Unit_1.Spell(data, unit));
41
41
  this.heroes = data.heroes.map((unit) => new Unit_1.Hero(data, unit));
42
42
  }
43
+ /** Whether this clan member is in the clan. */
44
+ get inClan() {
45
+ return this.clan !== null;
46
+ }
47
+ /** Whether this clan member is in the clan. */
48
+ get isMember() {
49
+ return this.clan ? this.role === 'member' : null;
50
+ }
51
+ /** Whether this clan member is a Leader. */
52
+ get isLeader() {
53
+ return this.clan ? this.role === 'leader' : null;
54
+ }
55
+ /** Whether this clan member is a Co-Leader. */
56
+ get isCoLeader() {
57
+ return this.clan ? this.role === 'coLeader' : null;
58
+ }
59
+ /** Whether this clan member is an Elder. */
60
+ get isElder() {
61
+ return this.clan ? this.role === 'elder' : null;
62
+ }
43
63
  /** Fetch detailed clan info for the player's clan. */
44
64
  async fetchClan(options) {
45
65
  if (!this.clan)
@@ -76,5 +96,9 @@ class Player {
76
96
  .filter((entry) => Constants_1.SIEGE_MACHINES.includes(entry.name))
77
97
  .sort((a, b) => Constants_1.SIEGE_MACHINES.indexOf(a.name) - Constants_1.SIEGE_MACHINES.indexOf(b.name));
78
98
  }
99
+ /** Get player's formatted link to open player in-game. */
100
+ get shareLink() {
101
+ return `https://link.clashofclans.com/en?action=OpenPlayerProfile&tag=${this.tag.replace(/#/g, '')}`;
102
+ }
79
103
  }
80
104
  exports.Player = Player;
@@ -19,4 +19,6 @@ export declare class PlayerClan {
19
19
  constructor(_client: Client, data: APIPlayerClan);
20
20
  /** Fetch detailed clan info for the player's clan. */
21
21
  fetch(options?: OverrideOptions): Promise<import("./Clan").Clan>;
22
+ /** Get clan's formatted link to open clan in-game. */
23
+ get shareLink(): string;
22
24
  }
@@ -15,5 +15,9 @@ class PlayerClan {
15
15
  fetch(options) {
16
16
  return this._client.getClan(this.tag, options);
17
17
  }
18
+ /** Get clan's formatted link to open clan in-game. */
19
+ get shareLink() {
20
+ return `https://link.clashofclans.com/en?action=OpenClanProfile&tag=${this.tag.replace(/#/g, '')}`;
21
+ }
18
22
  }
19
23
  exports.PlayerClan = PlayerClan;
@@ -23,6 +23,8 @@ export declare class SeasonRankedPlayer {
23
23
  /** The player's clan. */
24
24
  clan: PlayerClan | null;
25
25
  constructor(client: Client, data: Omit<APIPlayerRanking, 'league'>);
26
+ /** Get player's formatted link to open player in-game. */
27
+ get shareLink(): string;
26
28
  }
27
29
  /** Represents the Player of location based leader-board ranking. */
28
30
  export declare class RankedPlayer {
@@ -51,6 +53,8 @@ export declare class RankedPlayer {
51
53
  /** The player's league. If retrieving info for versus leader-boards, this will be `null`. */
52
54
  league: League | null;
53
55
  constructor(client: Client, data: APIPlayerRanking | APIPlayerVersusRanking);
56
+ /** Get player's formatted link to open player in-game. */
57
+ get shareLink(): string;
54
58
  }
55
59
  /** Represents the Clan of location based leader-board ranking. */
56
60
  export declare class RankedClan {
@@ -75,4 +79,6 @@ export declare class RankedClan {
75
79
  /** The clan's badge. */
76
80
  badge: Badge;
77
81
  constructor(data: APIClanRanking | APIClanVersusRanking);
82
+ /** Get clan's formatted link to open clan in-game. */
83
+ get shareLink(): string;
78
84
  }
@@ -19,6 +19,10 @@ class SeasonRankedPlayer {
19
19
  // @ts-expect-error
20
20
  this.clan = data.clan ? new PlayerClan_1.PlayerClan(client, data.clan) : null;
21
21
  }
22
+ /** Get player's formatted link to open player in-game. */
23
+ get shareLink() {
24
+ return `https://link.clashofclans.com/en?action=OpenPlayerProfile&tag=${this.tag.replace(/#/g, '')}`;
25
+ }
22
26
  }
23
27
  exports.SeasonRankedPlayer = SeasonRankedPlayer;
24
28
  /** Represents the Player of location based leader-board ranking. */
@@ -44,6 +48,10 @@ class RankedPlayer {
44
48
  // @ts-expect-error
45
49
  this.league = data.trophies ? new League_1.League(data.league ?? Constants_1.UNRANKED_LEAGUE_DATA) : null; // eslint-disable-line
46
50
  }
51
+ /** Get player's formatted link to open player in-game. */
52
+ get shareLink() {
53
+ return `https://link.clashofclans.com/en?action=OpenPlayerProfile&tag=${this.tag.replace(/#/g, '')}`;
54
+ }
47
55
  }
48
56
  exports.RankedPlayer = RankedPlayer;
49
57
  /** Represents the Clan of location based leader-board ranking. */
@@ -62,5 +70,9 @@ class RankedClan {
62
70
  this.previousRank = data.previousRank;
63
71
  this.badge = new Badge_1.Badge(data.badgeUrls);
64
72
  }
73
+ /** Get clan's formatted link to open clan in-game. */
74
+ get shareLink() {
75
+ return `https://link.clashofclans.com/en?action=OpenClanProfile&tag=${this.tag.replace(/#/g, '')}`;
76
+ }
65
77
  }
66
78
  exports.RankedClan = RankedClan;
@@ -46,6 +46,7 @@ export interface APIClan {
46
46
  clanVersusPoints: number;
47
47
  requiredTrophies: number;
48
48
  requiredTownhallLevel?: number;
49
+ requiredVersusTrophies?: number;
49
50
  warFrequency: 'always' | 'moreThanOncePerWeek' | 'oncePerWeek' | 'lessThanOncePerWeek' | 'never' | 'unknown';
50
51
  warWinStreak: number;
51
52
  warWins: number;
@@ -175,6 +176,7 @@ export interface APIPlayer {
175
176
  versusTrophies?: number;
176
177
  bestVersusTrophies?: number;
177
178
  versusBattleWins?: number;
179
+ versusBattleWinCount?: number;
178
180
  donations: number;
179
181
  donationsReceived: number;
180
182
  role?: string;
package/package.json CHANGED
@@ -1,13 +1,17 @@
1
1
  {
2
2
  "name": "clashofclans.js",
3
- "version": "2.6.1",
3
+ "version": "2.7.0",
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",
7
7
  "main": "dist/index.js",
8
- "types": "dist/index.d.ts",
8
+ "exports": {
9
+ "import": "./dist/index.mjs",
10
+ "require": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ },
9
13
  "scripts": {
10
- "build": "tsc",
14
+ "build": "tsc && gen-esm-wrapper dist/index.js dist/index.mjs",
11
15
  "prepare": "rimraf dist && npm run build",
12
16
  "test": "eslint --ext .ts --ignore-path .gitignore .",
13
17
  "lint": "eslint --fix --ext .ts --ignore-path .gitignore ."
@@ -104,6 +108,7 @@
104
108
  "eslint-config-marine": "^9.0.6",
105
109
  "eslint-config-prettier": "^8.3.0",
106
110
  "eslint-plugin-prettier": "^4.0.0",
111
+ "gen-esm-wrapper": "^1.1.3",
107
112
  "prettier": "^2.4.1",
108
113
  "rimraf": "^3.0.2",
109
114
  "typescript": "^4.5.2"