clashofclans.js 2.0.0-dev.ba3ae68 → 2.0.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,15 +2,16 @@
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.0
5
+ ## 2.0.0 (2021-11-26)
6
6
 
7
7
  This new version is a complete TypeScript rewrite to convert everything from plain (literal JSON) objects to class (constructor) objects and support a lot more features.
8
8
 
9
9
  ### Features
10
10
 
11
- - EventManager and Custom Events ([#37](https://github.com/clashperk/clashofclans.js/issues/37)) ([5027ae6](https://github.com/clashperk/clashofclans.js/commit/5027ae663a8e07175e17384c7e5706f4a1a7afb4)) ([984451d](https://github.com/clashperk/clashofclans.js/commit/30ea3240c11866008d0dae514468c0fdbb34ffd0))
12
- - Internal Caching Options ([#53](https://github.com/clashperk/clashofclans.js/issues/53))
13
- - Email Password Login ([#31](https://github.com/clashperk/clashofclans.js/issues/31)) ([4153cd3](https://github.com/clashperk/clashofclans.js/commit/4153cd37ea0e1c71550b9e892105b84d5a407e23))
14
11
  - API Date Parser and Request Retries ([#26](https://github.com/clashperk/clashofclans.js/issues/26)) ([94585f3](https://github.com/clashperk/clashofclans.js/commit/94585f3a84a7175b2d07872f9eb9e42372b95e12))
15
- - Override Request Options ([#36](https://github.com/clashperk/clashofclans.js/issues/36)) ([42d7fdd](https://github.com/clashperk/clashofclans.js/commit/42d7fdd36262cc46f23b731f8cffb9daea19d3b0))
12
+ - EventManager and Custom Events ([#37](https://github.com/clashperk/clashofclans.js/issues/37)) ([5027ae6](https://github.com/clashperk/clashofclans.js/commit/5027ae663a8e07175e17384c7e5706f4a1a7afb4))
13
+ - Email Password Login ([#31](https://github.com/clashperk/clashofclans.js/issues/31)) ([4153cd3](https://github.com/clashperk/clashofclans.js/commit/4153cd37ea0e1c71550b9e892105b84d5a407e23))
16
14
  - QueueThrottler and BatchThrottler ([#34](https://github.com/clashperk/clashofclans.js/issues/34)) ([3a8f051](https://github.com/clashperk/clashofclans.js/commit/3a8f051552e93b98f89bc7d524acdecddf242718))
15
+ - Override Request Options ([#36](https://github.com/clashperk/clashofclans.js/issues/36)) ([42d7fdd](https://github.com/clashperk/clashofclans.js/commit/42d7fdd36262cc46f23b731f8cffb9daea19d3b0))
16
+ - Internal Caching Options ([#53](https://github.com/clashperk/clashofclans.js/issues/53)) ([984451d](https://github.com/clashperk/clashofclans.js/commit/30ea3240c11866008d0dae514468c0fdbb34ffd0))
17
+ - Raw Data for Player Units ([#65](https://github.com/clashperk/clashofclans.js/pull/65)) ([aa1696](https://github.com/clashperk/clashofclans.js/commit/aa1696243d96d4fed0250b4282c60522a6482343))
package/README.md CHANGED
@@ -39,14 +39,14 @@ const client = new Client();
39
39
  ```js
40
40
  const { Client, BatchThrottler } = require('clashofclans.js');
41
41
  const client = new Client({
42
+ cache: true,
42
43
  retryLimit: 1,
43
- restRequestTimeout: 3000,
44
- throttler: new BatchThrottler(30)
44
+ restRequestTimeout: 5000,
45
+ throttler: new BatchThrottler(20)
45
46
  });
46
47
 
47
- client.events.addClans(['#8P2QG08P']);
48
- client.events.setEvent({
49
- type: 'CLAN',
48
+ client.events.addClans(['#8QU8J9LP', '#8P2QG08P']);
49
+ client.events.setClanEvent({
50
50
  name: 'clanDescriptionChange',
51
51
  filter: (oldClan, newClan) => {
52
52
  return oldClan.description !== newClan.description;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { ClanSearchOptions, SearchOptions, ClientOptions, InitOptions, OverrideOptions } from '../rest/RequestHandler';
3
- import { EVENTS } from '../util/Constants';
3
+ import { EVENTS, CWL_ROUNDS } from '../util/Constants';
4
4
  import { RESTManager } from '../rest/RESTManager';
5
5
  import { EventManager } from './EventManager';
6
6
  import { EventEmitter } from 'events';
@@ -21,6 +21,8 @@ export declare class Client extends EventEmitter {
21
21
  constructor(options?: ClientOptions);
22
22
  /** Contains various general-purpose utility methods. */
23
23
  get util(): typeof Util;
24
+ /** Whether the API is in maintenance break. */
25
+ get inMaintenance(): boolean;
24
26
  /**
25
27
  * Initialize the client to create keys.
26
28
  * @example
@@ -40,21 +42,47 @@ export declare class Client extends EventEmitter {
40
42
  getClanMembers(clanTag: string, options?: SearchOptions): Promise<ClanMember[]>;
41
43
  /** Get clan war log. */
42
44
  getClanWarLog(clanTag: string, options?: SearchOptions): Promise<ClanWarLog[]>;
43
- /** Get info about currently running war (regular or friendly) in the clan. */
44
- getClanWar(clanTag: string, options?: OverrideOptions): Promise<ClanWar | null>;
45
- /** Get info about currently running war in the clan. */
46
- getCurrentWar(clanTag: string, options?: OverrideOptions): Promise<ClanWar | null>;
47
- /** Get info about currently running CWL round. */
48
- getLeagueWar(clanTag: string, warState?: keyof typeof CWLRound): Promise<ClanWar | null>;
45
+ /** Get info about currently running war (normal or friendly) in the clan. */
46
+ getClanWar(clanTag: string, options?: OverrideOptions): Promise<ClanWar>;
47
+ /**
48
+ * Get info about currently running war in the clan.
49
+ * @example
50
+ * ```ts
51
+ * await client.getCurrentWar('#8QU8J9LP');
52
+ * ```
53
+ * @example
54
+ * ```ts
55
+ * await client.getCurrentWar({ clanTag: '#8QU8J9LP', round: 'PREVIOUS_ROUND' });
56
+ * ```
57
+ */
58
+ getCurrentWar(clanTag: string | {
59
+ clanTag: string;
60
+ round?: keyof typeof CWL_ROUNDS;
61
+ }, options?: OverrideOptions): Promise<ClanWar | null>;
62
+ /**
63
+ * Get info about currently running CWL round.
64
+ * @example
65
+ * ```ts
66
+ * await client.getLeagueWar('#8QU8J9LP');
67
+ * ```
68
+ * @example
69
+ * ```ts
70
+ * await client.getLeagueWar({ clanTag: '#8QU8J9LP', round: 'PREVIOUS_ROUND' });
71
+ * ```
72
+ */
73
+ getLeagueWar(clanTag: string | {
74
+ clanTag: string;
75
+ round?: keyof typeof CWL_ROUNDS;
76
+ }, options?: OverrideOptions): Promise<ClanWar | null>;
49
77
  private _getCurrentLeagueWars;
50
78
  private _getClanWars;
51
79
  /** Get information about clan war league. */
52
80
  getClanWarLeagueGroup(clanTag: string, options?: OverrideOptions): Promise<ClanWarLeagueGroup>;
53
- /** Get information about CWL round by WarTag. */
81
+ /** Get info about a CWL round by WarTag. */
54
82
  getClanWarLeagueRound(warTag: string | {
55
83
  warTag: string;
56
84
  clanTag?: string;
57
- }, options?: OverrideOptions): Promise<ClanWar | null>;
85
+ }, options?: OverrideOptions): Promise<ClanWar>;
58
86
  /** Get information about a player by tag. */
59
87
  getPlayer(playerTag: string, options?: OverrideOptions): Promise<Player>;
60
88
  /** Verify Player API token that can be found from the Game settings. */
@@ -73,9 +101,9 @@ export declare class Client extends EventEmitter {
73
101
  getClanRanks(locationId: number | 'global', options?: SearchOptions): Promise<RankedClan[]>;
74
102
  /** Get player rankings for a specific location. */
75
103
  getPlayerRanks(locationId: number | 'global', options?: SearchOptions): Promise<RankedPlayer[]>;
76
- /** Get clan versus rankings for a specific location */
104
+ /** Get clan versus rankings for a specific location. */
77
105
  getVersusClanRanks(locationId: number | 'global', options?: SearchOptions): Promise<RankedClan[]>;
78
- /** Get player versus rankings for a specific location */
106
+ /** Get player versus rankings for a specific location. */
79
107
  getVersusPlayerRanks(locationId: number | 'global', options?: SearchOptions): Promise<RankedPlayer[]>;
80
108
  /** Get list of clan labels. */
81
109
  getClanLabels(options?: SearchOptions): Promise<Label[]>;
@@ -88,8 +116,8 @@ export declare class Client extends EventEmitter {
88
116
  *
89
117
  * **Parameters**
90
118
  *
91
- * | Name | Type | Description |
92
- * | :--: | :--: | :---------: |
119
+ * | Name | Type | Description |
120
+ * | :--: | :------: | :-------------------: |
93
121
  * | `id` | `string` | Id of the new season. |
94
122
  * @public
95
123
  * @event
@@ -106,8 +134,8 @@ export declare class Client extends EventEmitter {
106
134
  *
107
135
  * **Parameters**
108
136
  *
109
- * | Name | Type | Description |
110
- * | :--: | :--: | :---------: |
137
+ * | Name | Type | Description |
138
+ * | :--------: | :------: | :------------------------------------------------: |
111
139
  * | `duration` | `number` | Duration of the maintenance break in milliseconds. |
112
140
  * @public
113
141
  * @event
@@ -115,15 +143,21 @@ export declare class Client extends EventEmitter {
115
143
  private static maintenanceEnd;
116
144
  /** @internal */
117
145
  on<K extends keyof ClientEvents>(event: K, listeners: (...args: ClientEvents[K]) => void): this;
146
+ /** @internal */
147
+ on<S extends keyof CustomEvents>(event: Exclude<S, keyof ClientEvents>, listeners: (...args: CustomEvents[S]) => void): this;
118
148
  /** @internal */ on<S extends string | symbol>(event: Exclude<S, keyof ClientEvents>, listeners: (...args: any[]) => void): this;
119
149
  /** @internal */
120
150
  once<K extends keyof ClientEvents>(event: K, listeners: (...args: ClientEvents[K]) => void): this;
151
+ /** @internal */
152
+ once<S extends keyof CustomEvents>(event: Exclude<S, keyof ClientEvents>, listeners: (...args: CustomEvents[S]) => void): this;
121
153
  /** @internal */ once<S extends string | symbol>(event: Exclude<S, keyof ClientEvents>, listeners: (...args: any[]) => void): this;
122
154
  /** @internal */
123
155
  emit<K extends keyof ClientEvents>(event: K, ...args: ClientEvents[K]): boolean;
156
+ /** @internal */
157
+ emit<S extends keyof CustomEvents>(event: Exclude<S, keyof ClientEvents>, ...args: CustomEvents[S]): this;
124
158
  /** @internal */ emit<S extends string | symbol>(event: Exclude<S, keyof ClientEvents>, ...args: any[]): boolean;
125
159
  }
126
- export interface ClientEvents {
160
+ interface ClientEvents {
127
161
  [EVENTS.NEW_SEASON_START]: [id: string];
128
162
  [EVENTS.MAINTENANCE_START]: [];
129
163
  [EVENTS.MAINTENANCE_END]: [duration: number];
@@ -135,13 +169,9 @@ export interface ClientEvents {
135
169
  [EVENTS.WAR_LOOP_END]: [];
136
170
  [EVENTS.ERROR]: [error: unknown];
137
171
  }
138
- export interface EventTypes {
139
- CLAN: [oldClan: Clan, newClan: Clan];
140
- PLAYER: [oldPlayer: Player, newPlayer: Player];
141
- CLAN_WAR: [oldWar: ClanWar, newWar: ClanWar];
172
+ interface CustomEvents {
173
+ [key: `clan${string}`]: [oldClan: Clan, newClan: Clan];
174
+ [key: `war${string}`]: [oldWar: ClanWar, newWar: ClanWar];
175
+ [key: `player${string}`]: [oldPlayer: Player, newPlayer: Player];
142
176
  }
143
- export declare const CWLRound: {
144
- readonly PREVIOUS_WAR: "warEnded";
145
- readonly CURRENT_WAR: "inWar";
146
- readonly NEXT_WAR: "preparation";
147
- };
177
+ export {};
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CWLRound = exports.Client = void 0;
3
+ exports.Client = void 0;
4
4
  const Constants_1 = require("../util/Constants");
5
+ const HTTPError_1 = require("../rest/HTTPError");
5
6
  const RESTManager_1 = require("../rest/RESTManager");
6
7
  const EventManager_1 = require("./EventManager");
7
- const HTTPError_1 = require("../rest/HTTPError");
8
8
  const events_1 = require("events");
9
9
  const Util_1 = require("../util/Util");
10
10
  const struct_1 = require("../struct");
@@ -25,6 +25,11 @@ class Client extends events_1.EventEmitter {
25
25
  get util() {
26
26
  return Util_1.Util;
27
27
  }
28
+ /** Whether the API is in maintenance break. */
29
+ get inMaintenance() {
30
+ // @ts-expect-error
31
+ return this.events._inMaintenance;
32
+ }
28
33
  /**
29
34
  * Initialize the client to create keys.
30
35
  * @example
@@ -62,30 +67,52 @@ class Client extends events_1.EventEmitter {
62
67
  const { data } = await this.rest.getClanWarLog(clanTag, options);
63
68
  return data.items.map((entry) => new struct_1.ClanWarLog(this, entry));
64
69
  }
65
- /** Get info about currently running war (regular or friendly) in the clan. */
70
+ /** Get info about currently running war (normal or friendly) in the clan. */
66
71
  async getClanWar(clanTag, options) {
67
- const { data, maxAge } = await this.rest.getCurrentWar(clanTag, options);
68
- if (data.state === 'notInWar')
69
- return null;
72
+ const { data, maxAge, path, status } = await this.rest.getCurrentWar(clanTag, options);
73
+ if (data.state === 'notInWar') {
74
+ throw new HTTPError_1.HTTPError(HTTPError_1.NotInWarError, status, path, maxAge);
75
+ }
70
76
  return new struct_1.ClanWar(this, data, { clanTag, maxAge });
71
77
  }
72
- /** Get info about currently running war in the clan. */
78
+ /**
79
+ * Get info about currently running war in the clan.
80
+ * @example
81
+ * ```ts
82
+ * await client.getCurrentWar('#8QU8J9LP');
83
+ * ```
84
+ * @example
85
+ * ```ts
86
+ * await client.getCurrentWar({ clanTag: '#8QU8J9LP', round: 'PREVIOUS_ROUND' });
87
+ * ```
88
+ */
73
89
  async getCurrentWar(clanTag, options) {
90
+ const args = typeof clanTag === 'string' ? { clanTag } : { clanTag: clanTag.clanTag, round: clanTag.round };
74
91
  try {
75
- const data = await this.getClanWar(clanTag, options);
76
- return data ?? (await this.getLeagueWar(clanTag));
92
+ return await this.getClanWar(args.clanTag, options);
77
93
  }
78
94
  catch (e) {
79
- if (e instanceof HTTPError_1.HTTPError && e.status === 403) {
80
- return this.getLeagueWar(clanTag);
95
+ if (e instanceof HTTPError_1.HTTPError && [200, 403].includes(e.status)) {
96
+ return this.getLeagueWar({ clanTag: args.clanTag, round: args.round }, options);
81
97
  }
98
+ throw e;
82
99
  }
83
- return null;
84
100
  }
85
- /** Get info about currently running CWL round. */
86
- async getLeagueWar(clanTag, warState) {
87
- const state = (warState && exports.CWLRound[warState]) ?? 'inWar'; // eslint-disable-line
88
- const data = await this.getClanWarLeagueGroup(clanTag);
101
+ /**
102
+ * Get info about currently running CWL round.
103
+ * @example
104
+ * ```ts
105
+ * await client.getLeagueWar('#8QU8J9LP');
106
+ * ```
107
+ * @example
108
+ * ```ts
109
+ * await client.getLeagueWar({ clanTag: '#8QU8J9LP', round: 'PREVIOUS_ROUND' });
110
+ * ```
111
+ */
112
+ async getLeagueWar(clanTag, options) {
113
+ const args = typeof clanTag === 'string' ? { clanTag } : { clanTag: clanTag.clanTag, round: clanTag.round };
114
+ const state = (args.round && Constants_1.CWL_ROUNDS[args.round]) ?? 'inWar'; // eslint-disable-line
115
+ const data = await this.getClanWarLeagueGroup(args.clanTag, options);
89
116
  const rounds = data.rounds.filter((round) => !round.warTags.includes('#0'));
90
117
  if (!rounds.length)
91
118
  return null;
@@ -95,29 +122,30 @@ class Client extends events_1.EventEmitter {
95
122
  .map((round) => round.warTags)
96
123
  .flat()
97
124
  .reverse();
98
- const wars = await this.util.allSettled(warTags.map((warTag) => this.getClanWarLeagueRound({ warTag, clanTag }, { ignoreRateLimit: true })));
99
- return wars.find((war) => war?.state === state) ?? wars.at(0) ?? null;
125
+ const wars = await this.util.allSettled(warTags.map((warTag) => this.getClanWarLeagueRound({ warTag, clanTag: args.clanTag }, { ...options, ignoreRateLimit: true })));
126
+ if (args.round && args.round in Constants_1.CWL_ROUNDS) {
127
+ return wars.find((war) => war.state === state) ?? null;
128
+ }
129
+ return wars.find((war) => war.state === state) ?? wars.at(0) ?? null;
100
130
  }
101
131
  async _getCurrentLeagueWars(clanTag, options) {
102
132
  const data = await this.getClanWarLeagueGroup(clanTag, options);
103
133
  // @ts-expect-error
104
- return data._getCurrentWars(clanTag);
134
+ return data._getCurrentWars(clanTag, options);
105
135
  }
106
136
  async _getClanWars(clanTag, options) {
107
- const date = new Date().getDate();
137
+ const date = new Date().getUTCDate();
138
+ if (!(date >= 1 && date <= 10)) {
139
+ return [await this.getClanWar(clanTag, options)];
140
+ }
108
141
  try {
109
- const data = await this.getClanWar(clanTag, options);
110
- if (!(date >= 1 && date <= 10))
111
- return data ? [data] : [];
112
- return data ? [data] : await this._getCurrentLeagueWars(clanTag);
142
+ return this._getCurrentLeagueWars(clanTag, options);
113
143
  }
114
144
  catch (e) {
115
- if (!(date >= 1 && date <= 10))
116
- return [];
117
- if (e instanceof HTTPError_1.HTTPError && e.status === 403) {
118
- return this._getCurrentLeagueWars(clanTag);
145
+ if (e instanceof HTTPError_1.HTTPError && [404].includes(e.status)) {
146
+ return [await this.getClanWar(clanTag, options)];
119
147
  }
120
- return [];
148
+ throw e;
121
149
  }
122
150
  }
123
151
  /** Get information about clan war league. */
@@ -125,12 +153,13 @@ class Client extends events_1.EventEmitter {
125
153
  const { data } = await this.rest.getClanWarLeagueGroup(clanTag, options);
126
154
  return new struct_1.ClanWarLeagueGroup(this, data);
127
155
  }
128
- /** Get information about CWL round by WarTag. */
156
+ /** Get info about a CWL round by WarTag. */
129
157
  async getClanWarLeagueRound(warTag, options) {
130
158
  const args = typeof warTag === 'string' ? { warTag } : { warTag: warTag.warTag, clanTag: warTag.clanTag };
131
- const { data, maxAge } = await this.rest.getClanWarLeagueRound(args.warTag, options);
132
- if (data.state === 'notInWar')
133
- return null;
159
+ const { data, maxAge, status, path } = await this.rest.getClanWarLeagueRound(args.warTag, options);
160
+ if (data.state === 'notInWar') {
161
+ throw new HTTPError_1.HTTPError(HTTPError_1.NotInWarError, status, path, maxAge);
162
+ }
134
163
  return new struct_1.ClanWar(this, data, { warTag: args.warTag, clanTag: args.clanTag, maxAge });
135
164
  }
136
165
  /** Get information about a player by tag. */
@@ -140,7 +169,7 @@ class Client extends events_1.EventEmitter {
140
169
  }
141
170
  /** Verify Player API token that can be found from the Game settings. */
142
171
  async verifyPlayerToken(playerTag, token, options) {
143
- const { data } = await this.rest.postPlayerToken(playerTag, token, options);
172
+ const { data } = await this.rest.verifyPlayerToken(playerTag, token, options);
144
173
  return data.status === 'ok';
145
174
  }
146
175
  /** Get list of Leagues. */
@@ -179,12 +208,12 @@ class Client extends events_1.EventEmitter {
179
208
  const { data } = await this.rest.getPlayerRanks(locationId, options);
180
209
  return data.items.map((entry) => new struct_1.RankedPlayer(this, entry));
181
210
  }
182
- /** Get clan versus rankings for a specific location */
211
+ /** Get clan versus rankings for a specific location. */
183
212
  async getVersusClanRanks(locationId, options) {
184
213
  const { data } = await this.rest.getVersusClanRanks(locationId, options);
185
214
  return data.items.map((entry) => new struct_1.RankedClan(entry));
186
215
  }
187
- /** Get player versus rankings for a specific location */
216
+ /** Get player versus rankings for a specific location. */
188
217
  async getVersusPlayerRanks(locationId, options) {
189
218
  const { data } = await this.rest.getVersusPlayerRanks(locationId, options);
190
219
  return data.items.map((entry) => new struct_1.RankedPlayer(this, entry));
@@ -206,8 +235,3 @@ class Client extends events_1.EventEmitter {
206
235
  }
207
236
  }
208
237
  exports.Client = Client;
209
- exports.CWLRound = {
210
- PREVIOUS_WAR: 'warEnded',
211
- CURRENT_WAR: 'inWar',
212
- NEXT_WAR: 'preparation'
213
- };
@@ -1,5 +1,6 @@
1
- import { EventTypes, Client } from './Client';
2
- /** Represents Event Manager of the {@link Client} class. */
1
+ import { Clan, ClanWar, Player } from '../struct';
2
+ import { Client } from './Client';
3
+ /** Represents Event Manager of the {@link Client}. */
3
4
  export declare class EventManager {
4
5
  private readonly client;
5
6
  private readonly _clanTags;
@@ -13,25 +14,29 @@ export declare class EventManager {
13
14
  private _maintenanceStartTime;
14
15
  constructor(client: Client);
15
16
  /** Initialize the Event Manager to start pulling. */
16
- init(): Promise<(string | symbol)[]>;
17
- addClans(...tags: string[]): this;
18
- deleteClans(...tags: string[]): this;
19
- addPlayers(...tags: string[]): this;
20
- deletePlayers(...tags: string[]): this;
21
- addWars(...tags: string[]): this;
22
- deleteWars(...tags: string[]): this;
17
+ init(): Promise<string[]>;
18
+ /** Add clan tags to clan events. */
19
+ addClans(tags: string[] | string): this;
20
+ /** Delete clan tags from clan events. */
21
+ deleteClans(tags: string[] | string): this;
22
+ /** Add player tags for player events. */
23
+ addPlayers(tags: string[] | string): this;
24
+ /** Delete player tags from player events. */
25
+ deletePlayers(tags: string[] | string): this;
26
+ /** Add clan tags for war events. */
27
+ addWars(tags: string[] | string): this;
28
+ /** Delete clan tags from war events. */
29
+ deleteWars(tags: string[] | string): this;
23
30
  /**
24
- * Set your own custom event.
25
- * @param event.type - `CLAN` | `PLAYER` | `CLAN_WAR`
26
- * @param event.name - Name of the event.
27
- * @param event.filter - Filter of this event. Must return a boolean value.
31
+ * Set your own custom clan event.
32
+ *
33
+ * In order to emit the custom event, you must have this filter function that returns a boolean.
28
34
  *
29
35
  * @example
30
36
  * ```js
31
- * client.events.addClans(['#2PP', '']);
37
+ * client.events.addClans(['#2PP', '#8QU8J9LP']);
32
38
  *
33
- * client.events.setEvent({
34
- * type: 'CLAN',
39
+ * client.events.setClanEvent({
35
40
  * name: 'clanMemberUpdate',
36
41
  * filter: (oldClan, newClan) => {
37
42
  * return oldClan.memberCount !== newClan.memberCount;
@@ -40,14 +45,35 @@ export declare class EventManager {
40
45
  *
41
46
  * client.on('clanMemberUpdate', (oldClan, newClan) => {
42
47
  * console.log(oldClan.memberCount, newClan.memberCount);
43
- * })
48
+ * });
49
+ *
50
+ * (async function () {
51
+ * await client.events.init();
52
+ * })();
44
53
  * ```
45
54
  * @returns
46
55
  */
47
- setEvent<K extends keyof EventTypes>(event: {
48
- type: K;
56
+ setClanEvent(event: {
57
+ name: string;
58
+ filter: (oldClan: Clan, newClan: Clan) => boolean;
59
+ }): this;
60
+ /**
61
+ * Set your own custom war event.
62
+ *
63
+ * In order to emit the custom event, you must have this filter function that returns a boolean.
64
+ */
65
+ setWarEvent(event: {
66
+ name: string;
67
+ filter: (oldWar: ClanWar, newWar: ClanWar) => boolean;
68
+ }): this;
69
+ /**
70
+ * Set your own custom player event.
71
+ *
72
+ * In order to emit the custom event, you must have this filter function that returns a boolean.
73
+ */
74
+ setPlayerEvent(event: {
49
75
  name: string;
50
- filter: (...args: EventTypes[K]) => boolean;
76
+ filter: (oldPlayer: Player, newPlayer: Player) => boolean;
51
77
  }): this;
52
78
  private maintenanceHandler;
53
79
  private seasonEndHandler;