clashofclans.js 2.6.0-dev.3d6d64a → 2.6.1-dev.96383c3
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 +8 -1
- package/dist/client/Client.js +1 -1
- package/dist/struct/Clan.d.ts +2 -0
- package/dist/struct/Clan.js +4 -0
- package/dist/struct/ClanWar.d.ts +4 -0
- package/dist/struct/ClanWar.js +8 -0
- package/dist/struct/ClanWarLeagueGroup.d.ts +4 -0
- package/dist/struct/ClanWarLeagueGroup.js +8 -0
- package/dist/struct/ClanWarLog.d.ts +2 -0
- package/dist/struct/ClanWarLog.js +4 -0
- package/dist/struct/Player.d.ts +2 -0
- package/dist/struct/Player.js +4 -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/util/Store.d.ts +2 -2
- package/dist/util/Util.js +5 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +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
|
-
|
|
5
|
+
# 2.6.1 (2022-02-03)
|
|
6
|
+
|
|
7
|
+
Bug Fixes
|
|
8
|
+
|
|
9
|
+
- New value and typings `notInWar` added for `ClanWarLeagueGroup#state` ([#101](https://github.com/clashperk/clashofclans.js/pull/101))
|
|
10
|
+
- Throw error if `Util.formatTag` / `Util.parseTag` is called with invalid argument ([#102](https://github.com/clashperk/clashofclans.js/pull/101))
|
|
11
|
+
|
|
12
|
+
## 2.6.0 (2022-01-29)
|
|
6
13
|
|
|
7
14
|
## Features
|
|
8
15
|
|
package/dist/client/Client.js
CHANGED
|
@@ -18,7 +18,7 @@ const struct_1 = require("../struct");
|
|
|
18
18
|
class Client extends events_1.EventEmitter {
|
|
19
19
|
constructor(options) {
|
|
20
20
|
super();
|
|
21
|
-
this.rest = new RESTManager_1.RESTManager(options);
|
|
21
|
+
this.rest = new RESTManager_1.RESTManager({ ...options, rejectIfNotValid: true });
|
|
22
22
|
this.events = new EventManager_1.EventManager(this);
|
|
23
23
|
}
|
|
24
24
|
/** Contains various general-purpose utility methods. */
|
package/dist/struct/Clan.d.ts
CHANGED
|
@@ -60,4 +60,6 @@ export declare class Clan {
|
|
|
60
60
|
constructor(client: Client, data: APIClan);
|
|
61
61
|
/** Get {@link Player} info for every Player in the clan. */
|
|
62
62
|
fetchMembers(options?: OverrideOptions): Promise<Player[]>;
|
|
63
|
+
/** Get clan's formatted link to open clan in-game. */
|
|
64
|
+
get shareLink(): string;
|
|
63
65
|
}
|
package/dist/struct/Clan.js
CHANGED
|
@@ -40,5 +40,9 @@ class Clan {
|
|
|
40
40
|
.filter((res) => res.status === 'fulfilled')
|
|
41
41
|
.map((res) => res.value);
|
|
42
42
|
}
|
|
43
|
+
/** Get clan's formatted link to open clan in-game. */
|
|
44
|
+
get shareLink() {
|
|
45
|
+
return `https://link.clashofclans.com/en?action=OpenClanProfile&tag=${this.tag.replace(/#/g, '')}`;
|
|
46
|
+
}
|
|
43
47
|
}
|
|
44
48
|
exports.Clan = Clan;
|
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 {
|
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. */
|
|
@@ -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 {
|
|
@@ -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. */
|
|
@@ -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;
|
|
@@ -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 {
|
package/dist/struct/Player.d.ts
CHANGED
package/dist/struct/Player.js
CHANGED
|
@@ -76,5 +76,9 @@ class Player {
|
|
|
76
76
|
.filter((entry) => Constants_1.SIEGE_MACHINES.includes(entry.name))
|
|
77
77
|
.sort((a, b) => Constants_1.SIEGE_MACHINES.indexOf(a.name) - Constants_1.SIEGE_MACHINES.indexOf(b.name));
|
|
78
78
|
}
|
|
79
|
+
/** Get player's formatted link to open player in-game. */
|
|
80
|
+
get shareLink() {
|
|
81
|
+
return `https://link.clashofclans.com/en?action=OpenPlayerProfile&tag=${this.tag.replace(/#/g, '')}`;
|
|
82
|
+
}
|
|
79
83
|
}
|
|
80
84
|
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/util/Store.d.ts
CHANGED
|
@@ -15,9 +15,9 @@ export interface CacheOptions {
|
|
|
15
15
|
*/
|
|
16
16
|
ttl?: number;
|
|
17
17
|
}
|
|
18
|
-
export declare class CacheStore<T
|
|
18
|
+
export declare class CacheStore<T> implements Store<T> {
|
|
19
19
|
private readonly ttl;
|
|
20
|
-
private readonly sweepInterval
|
|
20
|
+
private readonly sweepInterval;
|
|
21
21
|
private readonly store;
|
|
22
22
|
constructor(options?: CacheOptions);
|
|
23
23
|
private _sweep;
|
package/dist/util/Util.js
CHANGED
|
@@ -28,7 +28,10 @@ class Util extends null {
|
|
|
28
28
|
}
|
|
29
29
|
/** @internal */
|
|
30
30
|
static parseTag(tag) {
|
|
31
|
-
|
|
31
|
+
if (tag && typeof tag === 'string') {
|
|
32
|
+
return `#${tag.toUpperCase().replace(/O/g, '0').replace(/^#/g, '').replace(/\s/g, '')}`;
|
|
33
|
+
}
|
|
34
|
+
throw new TypeError('The "tag" argument must be of type string.');
|
|
32
35
|
}
|
|
33
36
|
/** Encodes a tag as a valid component of a URI. */
|
|
34
37
|
static encodeURI(tag) {
|
|
@@ -47,7 +50,7 @@ class Util extends null {
|
|
|
47
50
|
static encodeTag(tag) {
|
|
48
51
|
const formatted = this.formatTag(tag).substring(1);
|
|
49
52
|
if (!this.isValidTag(formatted)) {
|
|
50
|
-
throw new
|
|
53
|
+
throw new TypeError(`Failed to encode tag ${formatted}. RegExp matching failed.`);
|
|
51
54
|
}
|
|
52
55
|
const result = formatted.split('').reduce((sum, char) => sum * BigInt(14) + BigInt(TAG_CHARACTERS.indexOf(char)), BigInt(0));
|
|
53
56
|
return result.toString();
|
package/package.json
CHANGED