clashofclans.js 2.8.0 → 2.8.1
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 +7 -6
- package/dist/client/EventManager.js +1 -2
- package/dist/struct/Clan.d.ts +3 -0
- package/dist/struct/Clan.js +2 -0
- package/dist/struct/ClanCapital.d.ts +12 -0
- package/dist/struct/ClanCapital.js +10 -0
- package/dist/struct/ClanWarLeagueGroup.d.ts +2 -1
- package/dist/struct/ClanWarLeagueGroup.js +2 -1
- package/dist/struct/Player.d.ts +2 -0
- package/dist/struct/Player.js +1 -0
- package/dist/types/api.d.ts +10 -0
- package/package.json +1 -1
package/dist/client/Client.d.ts
CHANGED
|
@@ -74,8 +74,10 @@ export declare class Client extends EventEmitter {
|
|
|
74
74
|
clanTag: string;
|
|
75
75
|
round?: keyof typeof CWL_ROUNDS;
|
|
76
76
|
}, options?: OverrideOptions): Promise<ClanWar | null>;
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
/** Returns active wars (last 2) of the CWL group. */
|
|
78
|
+
getLeagueWars(clanTag: string, options?: OverrideOptions): Promise<ClanWar[]>;
|
|
79
|
+
/** Returns active wars (last 2 for CWL) of the clan. */
|
|
80
|
+
getWars(clanTag: string, options?: OverrideOptions): Promise<ClanWar[]>;
|
|
79
81
|
/** Get info about clan war league. */
|
|
80
82
|
getClanWarLeagueGroup(clanTag: string, options?: OverrideOptions): Promise<ClanWarLeagueGroup>;
|
|
81
83
|
/** Get info about a CWL round by WarTag. */
|
package/dist/client/Client.js
CHANGED
|
@@ -131,20 +131,21 @@ class Client extends events_1.EventEmitter {
|
|
|
131
131
|
if (args.round && args.round in Constants_1.CWL_ROUNDS) {
|
|
132
132
|
return wars.find((war) => war.clan.tag === args.clanTag && war.state === state) ?? null;
|
|
133
133
|
}
|
|
134
|
-
return wars.find((war) => war.clan.tag === args.clanTag
|
|
134
|
+
return wars.find((war) => war.clan.tag === args.clanTag) ?? null;
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
/** Returns active wars (last 2) of the CWL group. */
|
|
137
|
+
async getLeagueWars(clanTag, options) {
|
|
137
138
|
const data = await this.getClanWarLeagueGroup(clanTag, options);
|
|
138
|
-
|
|
139
|
-
return data._getCurrentWars(clanTag, options);
|
|
139
|
+
return data.getCurrentWars(clanTag, options);
|
|
140
140
|
}
|
|
141
|
-
|
|
141
|
+
/** Returns active wars (last 2 for CWL) of the clan. */
|
|
142
|
+
async getWars(clanTag, options) {
|
|
142
143
|
const date = new Date().getUTCDate();
|
|
143
144
|
if (!(date >= 1 && date <= 10)) {
|
|
144
145
|
return [await this.getClanWar(clanTag, options)];
|
|
145
146
|
}
|
|
146
147
|
try {
|
|
147
|
-
return this.
|
|
148
|
+
return this.getLeagueWars(clanTag, options);
|
|
148
149
|
}
|
|
149
150
|
catch (e) {
|
|
150
151
|
if (e instanceof HTTPError_1.HTTPError && [404].includes(e.status)) {
|
|
@@ -237,8 +237,7 @@ class EventManager {
|
|
|
237
237
|
async runWarUpdate(tag) {
|
|
238
238
|
if (this._inMaintenance)
|
|
239
239
|
return null;
|
|
240
|
-
|
|
241
|
-
const clanWars = await this.client._getClanWars(tag).catch(() => null);
|
|
240
|
+
const clanWars = await this.client.getWars(tag).catch(() => null);
|
|
242
241
|
if (!clanWars?.length)
|
|
243
242
|
return null;
|
|
244
243
|
clanWars.forEach(async (war, index) => {
|
package/dist/struct/Clan.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { Player } from './Player';
|
|
|
7
7
|
import { Location } from './Location';
|
|
8
8
|
import { Label } from './Label';
|
|
9
9
|
import { Badge } from './Badge';
|
|
10
|
+
import { ClanCapital } from './ClanCapital';
|
|
10
11
|
/** Represents a Clan. */
|
|
11
12
|
export declare class Clan {
|
|
12
13
|
client: Client;
|
|
@@ -54,6 +55,8 @@ export declare class Clan {
|
|
|
54
55
|
memberCount: number;
|
|
55
56
|
/** An array of {@link Label} that the clan has. */
|
|
56
57
|
labels: Label[];
|
|
58
|
+
/** The clan's Clan Capital information */
|
|
59
|
+
clanCapital: ClanCapital | null;
|
|
57
60
|
/**
|
|
58
61
|
* List of clan members.
|
|
59
62
|
* - This property returns empty array for {@link Client.getClans} method.
|
package/dist/struct/Clan.js
CHANGED
|
@@ -7,6 +7,7 @@ const WarLeague_1 = require("./WarLeague");
|
|
|
7
7
|
const Location_1 = require("./Location");
|
|
8
8
|
const Label_1 = require("./Label");
|
|
9
9
|
const Badge_1 = require("./Badge");
|
|
10
|
+
const ClanCapital_1 = require("./ClanCapital");
|
|
10
11
|
/** Represents a Clan. */
|
|
11
12
|
class Clan {
|
|
12
13
|
constructor(client, data) {
|
|
@@ -33,6 +34,7 @@ class Clan {
|
|
|
33
34
|
this.warLeague = data.warLeague ? new WarLeague_1.WarLeague(data.warLeague) : null;
|
|
34
35
|
this.memberCount = data.members;
|
|
35
36
|
this.labels = data.labels.map((label) => new Label_1.Label(label));
|
|
37
|
+
this.clanCapital = Object.keys(data.clanCapital).length > 0 ? new ClanCapital_1.ClanCapital(data.clanCapital) : null;
|
|
36
38
|
this.members = data.memberList?.map((mem) => new ClanMember_1.ClanMember(this.client, mem)) ?? []; // eslint-disable-line
|
|
37
39
|
}
|
|
38
40
|
/** Get {@link Player} info for every Player in the clan. */
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { APIClanCapital } from '../types';
|
|
2
|
+
export declare class ClanCapital {
|
|
3
|
+
/** The clan capital hall level */
|
|
4
|
+
capitalHallLevel: number | null;
|
|
5
|
+
/** The clan capital districts */
|
|
6
|
+
districts: {
|
|
7
|
+
id: number;
|
|
8
|
+
name: string;
|
|
9
|
+
districtHallLevel: number;
|
|
10
|
+
}[] | null;
|
|
11
|
+
constructor(data: APIClanCapital);
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClanCapital = void 0;
|
|
4
|
+
class ClanCapital {
|
|
5
|
+
constructor(data) {
|
|
6
|
+
this.capitalHallLevel = data.capitalHallLevel ?? null;
|
|
7
|
+
this.districts = data.districts ? data.districts : null;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.ClanCapital = ClanCapital;
|
|
@@ -62,7 +62,8 @@ export declare class ClanWarLeagueGroup {
|
|
|
62
62
|
* @param options Override options for the request.
|
|
63
63
|
*/
|
|
64
64
|
getWars(clanTag?: string, options?: OverrideOptions): Promise<ClanWar[]>;
|
|
65
|
-
|
|
65
|
+
/** Returns active wars (last 2) of the CWL group. */
|
|
66
|
+
getCurrentWars(clanTag: string, options?: OverrideOptions): Promise<ClanWar[]>;
|
|
66
67
|
/** Returns the index of the round for this specified warTag. */
|
|
67
68
|
getRoundIndex(warTag: string): number | null;
|
|
68
69
|
}
|
|
@@ -75,7 +75,8 @@ class ClanWarLeagueGroup {
|
|
|
75
75
|
.map((res) => res.value)
|
|
76
76
|
.filter((war) => (clanTag ? war.clan.tag === clanTag : true));
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
/** Returns active wars (last 2) of the CWL group. */
|
|
79
|
+
async getCurrentWars(clanTag, options) {
|
|
79
80
|
const rounds = this.rounds.filter((round) => !round.warTags.includes('#0'));
|
|
80
81
|
if (!rounds.length)
|
|
81
82
|
return [];
|
package/dist/struct/Player.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export declare class Player {
|
|
|
41
41
|
donations: number;
|
|
42
42
|
/** The player's donation received count for this season. */
|
|
43
43
|
received: number;
|
|
44
|
+
/** The player's total Clan Capital contribution */
|
|
45
|
+
clanCapitalContributions: number;
|
|
44
46
|
/** The player's role in the clan or `null` if not in a clan. */
|
|
45
47
|
role: 'member' | 'elder' | 'coLeader' | 'leader' | null;
|
|
46
48
|
/** Whether the player has selected that they are opted in. This will be `null` if the player is not in a clan. */
|
package/dist/struct/Player.js
CHANGED
|
@@ -28,6 +28,7 @@ class Player {
|
|
|
28
28
|
this.versusBattleWins = data.versusBattleWins ?? null;
|
|
29
29
|
this.donations = data.donations;
|
|
30
30
|
this.received = data.donationsReceived;
|
|
31
|
+
this.clanCapitalContributions = data.clanCapitalContributions;
|
|
31
32
|
// @ts-expect-error
|
|
32
33
|
this.role = data.role?.replace('admin', 'elder') ?? null;
|
|
33
34
|
this.warOptedIn = data.warPreference ? data.warPreference === 'in' : null;
|
package/dist/types/api.d.ts
CHANGED
|
@@ -57,6 +57,7 @@ export interface APIClan {
|
|
|
57
57
|
members: number;
|
|
58
58
|
labels: APILabel[];
|
|
59
59
|
memberList: APIClanMember[];
|
|
60
|
+
clanCapital: APIClanCapital;
|
|
60
61
|
}
|
|
61
62
|
export interface APIClanMember {
|
|
62
63
|
name: string;
|
|
@@ -71,6 +72,14 @@ export interface APIClanMember {
|
|
|
71
72
|
donations: number;
|
|
72
73
|
donationsReceived: number;
|
|
73
74
|
}
|
|
75
|
+
export interface APIClanCapital {
|
|
76
|
+
capitalHallLevel?: number;
|
|
77
|
+
districts?: {
|
|
78
|
+
id: number;
|
|
79
|
+
name: string;
|
|
80
|
+
districtHallLevel: number;
|
|
81
|
+
}[];
|
|
82
|
+
}
|
|
74
83
|
/** /clans/{clanTag}/members */
|
|
75
84
|
export interface APIClanMemberList {
|
|
76
85
|
items: APIClanMember[];
|
|
@@ -179,6 +188,7 @@ export interface APIPlayer {
|
|
|
179
188
|
versusBattleWinCount?: number;
|
|
180
189
|
donations: number;
|
|
181
190
|
donationsReceived: number;
|
|
191
|
+
clanCapitalContributions: number;
|
|
182
192
|
role?: string;
|
|
183
193
|
warPreference?: 'in' | 'out';
|
|
184
194
|
clan?: APIPlayerClan;
|