clashofclans.js 2.6.1 → 2.7.0-dev.31f642e
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 +4 -2
- package/dist/client/Client.js +12 -1
- package/dist/index.mjs +66 -0
- package/dist/struct/Clan.d.ts +4 -0
- package/dist/struct/Clan.js +5 -0
- package/dist/struct/ClanMember.d.ts +4 -0
- package/dist/struct/ClanMember.js +12 -0
- package/dist/struct/ClanWar.d.ts +9 -0
- package/dist/struct/ClanWar.js +21 -0
- package/dist/struct/ClanWarLeagueGroup.d.ts +5 -0
- package/dist/struct/ClanWarLeagueGroup.js +11 -0
- package/dist/struct/ClanWarLog.d.ts +5 -0
- package/dist/struct/ClanWarLog.js +13 -0
- package/dist/struct/Player.d.ts +7 -0
- package/dist/struct/Player.js +19 -0
- package/dist/struct/PlayerClan.d.ts +2 -0
- package/dist/struct/PlayerClan.js +4 -0
- package/dist/struct/Ranking.d.ts +6 -0
- package/dist/struct/Ranking.js +12 -0
- package/dist/types/api.d.ts +2 -0
- package/dist/util/Util.d.ts +3 -0
- package/dist/util/Util.js +12 -0
- package/package.json +8 -3
package/dist/client/Client.d.ts
CHANGED
|
@@ -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
|
|
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. */
|
package/dist/client/Client.js
CHANGED
|
@@ -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
|
|
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;
|
package/dist/struct/Clan.d.ts
CHANGED
|
@@ -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
|
}
|
package/dist/struct/Clan.js
CHANGED
|
@@ -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,10 @@ 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
|
+
get isMember(): boolean;
|
|
30
|
+
get isElder(): boolean;
|
|
31
|
+
get isCoLeader(): boolean;
|
|
32
|
+
get isLeader(): boolean;
|
|
29
33
|
/** Fetch detailed clan info for the member's clan. */
|
|
30
34
|
fetch(options?: OverrideOptions): Promise<import("./Player").Player>;
|
|
31
35
|
}
|
|
@@ -20,6 +20,18 @@ class ClanMember {
|
|
|
20
20
|
this.donations = data.donations;
|
|
21
21
|
this.received = data.donationsReceived;
|
|
22
22
|
}
|
|
23
|
+
get isMember() {
|
|
24
|
+
return this.role === 'member';
|
|
25
|
+
}
|
|
26
|
+
get isElder() {
|
|
27
|
+
return this.role === 'elder';
|
|
28
|
+
}
|
|
29
|
+
get isCoLeader() {
|
|
30
|
+
return this.role === 'coLeader';
|
|
31
|
+
}
|
|
32
|
+
get isLeader() {
|
|
33
|
+
return this.role === 'leader';
|
|
34
|
+
}
|
|
23
35
|
/** Fetch detailed clan info for the member's clan. */
|
|
24
36
|
async fetch(options) {
|
|
25
37
|
return this.client.getPlayer(this.tag, options);
|
package/dist/struct/ClanWar.d.ts
CHANGED
|
@@ -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,17 @@ 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
|
+
get isBattleDay(): boolean;
|
|
139
|
+
get isPreparationDay(): boolean;
|
|
140
|
+
get isWarEnded(): boolean;
|
|
134
141
|
/** Returns either `friendly`, `cwl` or `normal`. */
|
|
135
142
|
get type(): "friendly" | "cwl" | "normal";
|
|
136
143
|
/** Whether this is a friendly war. */
|
|
137
144
|
get isFriendly(): boolean;
|
|
138
145
|
/** Whether this is a CWL. */
|
|
139
146
|
get isCWL(): boolean;
|
|
147
|
+
/** Whether this is a normal war. */
|
|
148
|
+
get isNormal(): boolean;
|
|
140
149
|
/** Returns the war status, based off the home clan. */
|
|
141
150
|
get status(): "win" | "lose" | "tie" | "pending";
|
|
142
151
|
/** Returns the Clan War League Group. */
|
package/dist/struct/ClanWar.js
CHANGED
|
@@ -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,15 @@ class ClanWar {
|
|
|
170
178
|
}
|
|
171
179
|
return this.opponent.attacks.filter((atk) => atk.defenderTag === defenderTag);
|
|
172
180
|
}
|
|
181
|
+
get isBattleDay() {
|
|
182
|
+
return this.state === 'inWar';
|
|
183
|
+
}
|
|
184
|
+
get isPreparationDay() {
|
|
185
|
+
return this.state === 'preparation';
|
|
186
|
+
}
|
|
187
|
+
get isWarEnded() {
|
|
188
|
+
return this.state === 'warEnded';
|
|
189
|
+
}
|
|
173
190
|
/** Returns either `friendly`, `cwl` or `normal`. */
|
|
174
191
|
get type() {
|
|
175
192
|
if (this.isFriendly)
|
|
@@ -187,6 +204,10 @@ class ClanWar {
|
|
|
187
204
|
get isCWL() {
|
|
188
205
|
return typeof this.warTag === 'string';
|
|
189
206
|
}
|
|
207
|
+
/** Whether this is a normal war. */
|
|
208
|
+
get isNormal() {
|
|
209
|
+
return !this.isCWL && !this.isFriendly;
|
|
210
|
+
}
|
|
190
211
|
/** Returns the war status, based off the home clan. */
|
|
191
212
|
get status() {
|
|
192
213
|
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,7 @@ 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
|
+
get totalRounds(): number;
|
|
53
58
|
/**
|
|
54
59
|
* This returns an array of {@link ClanWar} which fetches all wars in parallel.
|
|
55
60
|
* @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,9 @@ 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
|
+
get totalRounds() {
|
|
59
|
+
return this.clans.length - 1;
|
|
60
|
+
}
|
|
50
61
|
/**
|
|
51
62
|
* This returns an array of {@link ClanWar} which fetches all wars in parallel.
|
|
52
63
|
* @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,7 @@ 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
|
+
get isFriendly(): boolean;
|
|
55
|
+
get isCWL(): boolean;
|
|
56
|
+
get isNormal(): boolean;
|
|
52
57
|
}
|
|
@@ -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,14 @@ class ClanWarLog {
|
|
|
40
44
|
return 'cwl';
|
|
41
45
|
return 'normal';
|
|
42
46
|
}
|
|
47
|
+
get isFriendly() {
|
|
48
|
+
return this.type === 'friendly';
|
|
49
|
+
}
|
|
50
|
+
get isCWL() {
|
|
51
|
+
return this.type === 'cwl';
|
|
52
|
+
}
|
|
53
|
+
get isNormal() {
|
|
54
|
+
return this.type === 'normal';
|
|
55
|
+
}
|
|
43
56
|
}
|
|
44
57
|
exports.ClanWarLog = ClanWarLog;
|
package/dist/struct/Player.d.ts
CHANGED
|
@@ -62,6 +62,11 @@ 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
|
+
get inClan(): boolean;
|
|
66
|
+
get isMember(): boolean | null;
|
|
67
|
+
get isLeader(): boolean | null;
|
|
68
|
+
get isCoLeader(): boolean | null;
|
|
69
|
+
get isElder(): boolean | null;
|
|
65
70
|
/** Fetch detailed clan info for the player's clan. */
|
|
66
71
|
fetchClan(options?: OverrideOptions): Promise<import("./Clan").Clan | null>;
|
|
67
72
|
/** An array of the player's home base troops. */
|
|
@@ -74,4 +79,6 @@ export declare class Player {
|
|
|
74
79
|
get heroPets(): Troop[];
|
|
75
80
|
/** An array of the player's siege machines. */
|
|
76
81
|
get siegeMachines(): Troop[];
|
|
82
|
+
/** Get player's formatted link to open player in-game. */
|
|
83
|
+
get shareLink(): string;
|
|
77
84
|
}
|
package/dist/struct/Player.js
CHANGED
|
@@ -40,6 +40,21 @@ 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
|
+
get inClan() {
|
|
44
|
+
return this.clan !== null;
|
|
45
|
+
}
|
|
46
|
+
get isMember() {
|
|
47
|
+
return this.clan ? this.role === 'member' : null;
|
|
48
|
+
}
|
|
49
|
+
get isLeader() {
|
|
50
|
+
return this.clan ? this.role === 'leader' : null;
|
|
51
|
+
}
|
|
52
|
+
get isCoLeader() {
|
|
53
|
+
return this.clan ? this.role === 'coLeader' : null;
|
|
54
|
+
}
|
|
55
|
+
get isElder() {
|
|
56
|
+
return this.clan ? this.role === 'elder' : null;
|
|
57
|
+
}
|
|
43
58
|
/** Fetch detailed clan info for the player's clan. */
|
|
44
59
|
async fetchClan(options) {
|
|
45
60
|
if (!this.clan)
|
|
@@ -76,5 +91,9 @@ class Player {
|
|
|
76
91
|
.filter((entry) => Constants_1.SIEGE_MACHINES.includes(entry.name))
|
|
77
92
|
.sort((a, b) => Constants_1.SIEGE_MACHINES.indexOf(a.name) - Constants_1.SIEGE_MACHINES.indexOf(b.name));
|
|
78
93
|
}
|
|
94
|
+
/** Get player's formatted link to open player in-game. */
|
|
95
|
+
get shareLink() {
|
|
96
|
+
return `https://link.clashofclans.com/en?action=OpenPlayerProfile&tag=${this.tag.replace(/#/g, '')}`;
|
|
97
|
+
}
|
|
79
98
|
}
|
|
80
99
|
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;
|
package/dist/struct/Ranking.d.ts
CHANGED
|
@@ -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
|
}
|
package/dist/struct/Ranking.js
CHANGED
|
@@ -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;
|
package/dist/types/api.d.ts
CHANGED
|
@@ -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/dist/util/Util.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Clan, ClanMember } from '../struct';
|
|
1
2
|
import { ClanSearchOptions, SearchOptions } from '../types';
|
|
2
3
|
/** Contains various general-purpose utility methods. */
|
|
3
4
|
export declare class Util extends null {
|
|
@@ -39,4 +40,6 @@ export declare class Util extends null {
|
|
|
39
40
|
static getSeasonEndTime(timestamp?: Date): Date;
|
|
40
41
|
static allSettled<T>(values: Promise<T>[]): Promise<T[]>;
|
|
41
42
|
static delay(ms: number): Promise<unknown>;
|
|
43
|
+
static joinedMembers(oldClan: Clan, newClan: Clan): ClanMember[];
|
|
44
|
+
static leftMembers(oldClan: Clan, newClan: Clan): ClanMember[];
|
|
42
45
|
}
|
package/dist/util/Util.js
CHANGED
|
@@ -111,5 +111,17 @@ class Util extends null {
|
|
|
111
111
|
static async delay(ms) {
|
|
112
112
|
return new Promise((res) => setTimeout(res, ms));
|
|
113
113
|
}
|
|
114
|
+
static joinedMembers(oldClan, newClan) {
|
|
115
|
+
const oldMembers = oldClan.members.map((member) => member.tag);
|
|
116
|
+
return newClan.members.filter((member) => {
|
|
117
|
+
return !oldMembers.includes(member.tag);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
static leftMembers(oldClan, newClan) {
|
|
121
|
+
const newMembers = newClan.members.map((member) => member.tag);
|
|
122
|
+
return oldClan.members.filter((member) => {
|
|
123
|
+
return !newMembers.includes(member.tag);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
114
126
|
}
|
|
115
127
|
exports.Util = Util;
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clashofclans.js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0-dev.31f642e",
|
|
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
|
-
"
|
|
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"
|