clashofclans.js 2.8.4 → 3.0.0-dev.f6ce42f

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.
@@ -46,7 +46,7 @@ class RankedPlayer {
46
46
  // @ts-expect-error
47
47
  this.clan = data.clan ? new PlayerClan_1.PlayerClan(client, data.clan) : null;
48
48
  // @ts-expect-error
49
- this.league = data.trophies ? new League_1.League(data.league ?? Constants_1.UNRANKED_LEAGUE_DATA) : null; // eslint-disable-line
49
+ this.league = data.trophies ? new League_1.League(data.league ?? Constants_1.UnrankedLeagueData) : null; // eslint-disable-line
50
50
  }
51
51
  /** Get player's formatted link to open player in-game. */
52
52
  get shareLink() {
@@ -10,14 +10,14 @@ class Unit {
10
10
  this.level = unit.level;
11
11
  this.maxLevel = unit.maxLevel;
12
12
  this.village = unit.village;
13
- const rawSuperUnit = Constants_1.RAW_DATA.RAW_SUPER_UNITS.find((unit) => unit.name === this.name && this.isHomeBase);
14
- const rawUnit = Constants_1.RAW_DATA.RAW_UNITS.find((unit) => unit.name === this.name && unit.village === this.village);
13
+ const rawSuperUnit = Constants_1.RawData.RawSuperUnits.find((unit) => unit.name === this.name && this.isHomeBase);
14
+ const rawUnit = Constants_1.RawData.RawUnits.find((unit) => unit.name === this.name && unit.village === this.village);
15
15
  if (rawSuperUnit) {
16
16
  this.id = rawSuperUnit.id;
17
17
  this.housingSpace = rawSuperUnit.housingSpace;
18
18
  this.originalName = rawSuperUnit.original;
19
19
  this.minOriginalLevel = rawSuperUnit.minOriginalLevel;
20
- const original = Constants_1.RAW_DATA.RAW_UNITS.find((unit) => unit.village === 'home' && unit.name === rawSuperUnit.original);
20
+ const original = Constants_1.RawData.RawUnits.find((unit) => unit.village === 'home' && unit.name === rawSuperUnit.original);
21
21
  this.unlockHallLevel = original.levels.findIndex((level) => level >= rawSuperUnit.minOriginalLevel) + 1;
22
22
  this.unlockCost = original.unlock.cost;
23
23
  this.unlockTime = original.unlock.time;
@@ -87,7 +87,7 @@ class Troop extends Unit {
87
87
  }
88
88
  /** Whether this troop is a Super Troop. */
89
89
  get isSuperTroop() {
90
- return this.isActive || (this.isHomeBase && Constants_1.SUPER_TROOPS.includes(this.name));
90
+ return this.isActive || (this.isHomeBase && Constants_1.SuperTroops.includes(this.name));
91
91
  }
92
92
  }
93
93
  exports.Troop = Troop;
@@ -10,7 +10,7 @@ class WarLeague {
10
10
  }
11
11
  /** Position of this War League. Starting from 0 (Unranked) */
12
12
  get position() {
13
- return Constants_1.WAR_LEAGUES.indexOf(this.id);
13
+ return Constants_1.WarLeagues.indexOf(this.id);
14
14
  }
15
15
  }
16
16
  exports.WarLeague = WarLeague;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,9 +1,9 @@
1
1
  import { QueueThrottler, BatchThrottler } from '../rest/Throttler';
2
2
  export interface Store<T = any> {
3
- set(key: string, value: T, ttl?: number): boolean | Promise<boolean>;
4
- get(key: string): T | null | Promise<T | null>;
5
- delete(key: string): boolean | Promise<boolean>;
6
- clear(): void | Promise<void>;
3
+ set: (key: string, value: T, ttl?: number) => boolean | Promise<boolean>;
4
+ get: (key: string) => T | null | Promise<T | null>;
5
+ delete: (key: string) => boolean | Promise<boolean>;
6
+ clear: () => void | Promise<void>;
7
7
  }
8
8
  /** Options for a {@link Client} */
9
9
  export interface ClientOptions {
@@ -1,17 +1,17 @@
1
- export declare const API_BASE_URL = "https://api.clashofclans.com/v1";
2
- export declare const DEV_SITE_API_BASE_URL = "https://developer.clashofclans.com/api";
3
- export declare const ELIXIR_TROOPS: string[];
4
- export declare const DARK_ELIXIR_TROOPS: string[];
5
- export declare const HOME_TROOPS: string[];
6
- export declare const SIEGE_MACHINES: string[];
7
- export declare const SUPER_TROOPS: string[];
8
- export declare const ELIXIR_SPELLS: string[];
9
- export declare const DARK_ELIXIR_SPELLS: string[];
10
- export declare const SPELLS: string[];
11
- export declare const BUILDER_TROOPS: string[];
12
- export declare const HEROES: string[];
13
- export declare const HERO_PETS: string[];
14
- export declare const UNRANKED_LEAGUE_DATA: {
1
+ export declare const APIBaseURL = "https://api.clashofclans.com/v1";
2
+ export declare const DevSiteAPIBaseURL = "https://developer.clashofclans.com/api";
3
+ export declare const ElixirTroops: string[];
4
+ export declare const DarkElixirTroops: string[];
5
+ export declare const HomeTroops: string[];
6
+ export declare const SiegeMachines: string[];
7
+ export declare const SuperTroops: string[];
8
+ export declare const ElixirSpells: string[];
9
+ export declare const DarkElixirSpells: string[];
10
+ export declare const Spells: string[];
11
+ export declare const BuilderTroops: string[];
12
+ export declare const Heroes: string[];
13
+ export declare const HeroPets: string[];
14
+ export declare const UnrankedLeagueData: {
15
15
  id: number;
16
16
  name: string;
17
17
  iconUrls: {
@@ -19,30 +19,34 @@ export declare const UNRANKED_LEAGUE_DATA: {
19
19
  tiny: string;
20
20
  };
21
21
  };
22
- export declare const LEGEND_LEAGUE_ID = 29000022;
23
- export declare const LEAGUES: number[];
24
- export declare const WAR_LEAGUES: number[];
25
- export declare const FRIENDLY_WAR_PREPARATION_TIMES: readonly [number, number, number, number, number, number, number, number, number, number, number, number];
26
- export declare const EVENTS: {
27
- readonly NEW_SEASON_START: "newSeasonStart";
28
- readonly CLAN_LOOP_START: "clanLoopStart";
29
- readonly CLAN_LOOP_END: "clanLoopEnd";
30
- readonly PLAYER_LOOP_START: "playerLoopStart";
31
- readonly PLAYER_LOOP_END: "playerLoopEnd";
32
- readonly WAR_LOOP_START: "warLoopEnd";
33
- readonly WAR_LOOP_END: "warLoopEnd";
34
- readonly MAINTENANCE_START: "maintenanceStart";
35
- readonly MAINTENANCE_END: "maintenanceEnd";
36
- readonly ERROR: "error";
37
- readonly DEBUG: "debug";
22
+ export declare const LegendLeagueId = 29000022;
23
+ export declare const Leagues: number[];
24
+ export declare const WarLeagues: number[];
25
+ export declare const FriendlyWarPreparationTimes: readonly [number, number, number, number, number, number, number, number, number, number, number, number];
26
+ export declare const PollingEvents: {
27
+ readonly NewSeasonStart: "newSeasonStart";
28
+ readonly ClanLoopStart: "clanLoopStart";
29
+ readonly ClanLoopEnd: "clanLoopEnd";
30
+ readonly PlayerLoopStart: "playerLoopStart";
31
+ readonly PlayerLoopEnd: "playerLoopEnd";
32
+ readonly WarLoopStart: "warLoopEnd";
33
+ readonly WarLoopEnd: "warLoopEnd";
34
+ readonly MaintenanceStart: "maintenanceStart";
35
+ readonly MaintenanceEnd: "maintenanceEnd";
36
+ readonly Error: "error";
37
+ readonly Debug: "debug";
38
38
  };
39
- export declare const CWL_ROUNDS: {
40
- readonly PREVIOUS_ROUND: "warEnded";
41
- readonly CURRENT_ROUND: "inWar";
42
- readonly NEXT_ROUND: "preparation";
39
+ export declare const RestEvents: {
40
+ readonly Error: "error";
41
+ readonly Debug: "debug";
43
42
  };
44
- export declare const RAW_DATA: {
45
- RAW_UNITS: {
43
+ export declare const CWLRounds: {
44
+ readonly PreviousRound: "warEnded";
45
+ readonly CurrentRound: "inWar";
46
+ readonly NextRound: "preparation";
47
+ };
48
+ export declare const RawData: {
49
+ RawUnits: {
46
50
  id: number;
47
51
  name: string;
48
52
  housingSpace: number;
@@ -69,7 +73,7 @@ export declare const RAW_DATA: {
69
73
  seasonal: boolean;
70
74
  levels: number[];
71
75
  }[];
72
- RAW_SUPER_UNITS: {
76
+ RawSuperUnits: {
73
77
  name: string;
74
78
  id: number;
75
79
  original: string;
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.RAW_DATA = exports.CWL_ROUNDS = exports.EVENTS = exports.FRIENDLY_WAR_PREPARATION_TIMES = exports.WAR_LEAGUES = exports.LEAGUES = exports.LEGEND_LEAGUE_ID = exports.UNRANKED_LEAGUE_DATA = exports.HERO_PETS = exports.HEROES = exports.BUILDER_TROOPS = exports.SPELLS = exports.DARK_ELIXIR_SPELLS = exports.ELIXIR_SPELLS = exports.SUPER_TROOPS = exports.SIEGE_MACHINES = exports.HOME_TROOPS = exports.DARK_ELIXIR_TROOPS = exports.ELIXIR_TROOPS = exports.DEV_SITE_API_BASE_URL = exports.API_BASE_URL = void 0;
6
+ exports.RawData = exports.CWLRounds = exports.RestEvents = exports.PollingEvents = exports.FriendlyWarPreparationTimes = exports.WarLeagues = exports.Leagues = exports.LegendLeagueId = exports.UnrankedLeagueData = exports.HeroPets = exports.Heroes = exports.BuilderTroops = exports.Spells = exports.DarkElixirSpells = exports.ElixirSpells = exports.SuperTroops = exports.SiegeMachines = exports.HomeTroops = exports.DarkElixirTroops = exports.ElixirTroops = exports.DevSiteAPIBaseURL = exports.APIBaseURL = void 0;
7
7
  const raw_json_1 = __importDefault(require("../util/raw.json"));
8
- exports.API_BASE_URL = 'https://api.clashofclans.com/v1';
9
- exports.DEV_SITE_API_BASE_URL = 'https://developer.clashofclans.com/api';
10
- exports.ELIXIR_TROOPS = [
8
+ exports.APIBaseURL = 'https://api.clashofclans.com/v1';
9
+ exports.DevSiteAPIBaseURL = 'https://developer.clashofclans.com/api';
10
+ exports.ElixirTroops = [
11
11
  'Barbarian',
12
12
  'Archer',
13
13
  'Giant',
@@ -24,10 +24,10 @@ exports.ELIXIR_TROOPS = [
24
24
  'Yeti',
25
25
  'Dragon Rider'
26
26
  ];
27
- exports.DARK_ELIXIR_TROOPS = ['Minion', 'Hog Rider', 'Valkyrie', 'Golem', 'Witch', 'Lava Hound', 'Bowler', 'Ice Golem', 'Headhunter'];
28
- exports.HOME_TROOPS = [...exports.ELIXIR_TROOPS, ...exports.DARK_ELIXIR_TROOPS];
29
- exports.SIEGE_MACHINES = ['Wall Wrecker', 'Battle Blimp', 'Stone Slammer', 'Siege Barracks', 'Log Launcher', 'Flame Flinger'];
30
- exports.SUPER_TROOPS = [
27
+ exports.DarkElixirTroops = ['Minion', 'Hog Rider', 'Valkyrie', 'Golem', 'Witch', 'Lava Hound', 'Bowler', 'Ice Golem', 'Headhunter'];
28
+ exports.HomeTroops = [...exports.ElixirTroops, ...exports.DarkElixirTroops];
29
+ exports.SiegeMachines = ['Wall Wrecker', 'Battle Blimp', 'Stone Slammer', 'Siege Barracks', 'Log Launcher', 'Flame Flinger'];
30
+ exports.SuperTroops = [
31
31
  'Super Barbarian',
32
32
  'Super Archer',
33
33
  'Super Giant',
@@ -43,7 +43,7 @@ exports.SUPER_TROOPS = [
43
43
  'Ice Hound',
44
44
  'Super Bowler'
45
45
  ];
46
- exports.ELIXIR_SPELLS = [
46
+ exports.ElixirSpells = [
47
47
  'Lightning Spell',
48
48
  'Healing Spell',
49
49
  'Rage Spell',
@@ -52,9 +52,9 @@ exports.ELIXIR_SPELLS = [
52
52
  'Clone Spell',
53
53
  'Invisibility Spell'
54
54
  ];
55
- exports.DARK_ELIXIR_SPELLS = ['Poison Spell', 'Earthquake Spell', 'Haste Spell', 'Skeleton Spell', 'Bat Spell'];
56
- exports.SPELLS = [...exports.ELIXIR_SPELLS, ...exports.DARK_ELIXIR_SPELLS];
57
- exports.BUILDER_TROOPS = [
55
+ exports.DarkElixirSpells = ['Poison Spell', 'Earthquake Spell', 'Haste Spell', 'Skeleton Spell', 'Bat Spell'];
56
+ exports.Spells = [...exports.ElixirSpells, ...exports.DarkElixirSpells];
57
+ exports.BuilderTroops = [
58
58
  'Raged Barbarian',
59
59
  'Sneaky Archer',
60
60
  'Boxer Giant',
@@ -67,9 +67,9 @@ exports.BUILDER_TROOPS = [
67
67
  'Super P.E.K.K.A',
68
68
  'Hog Glider'
69
69
  ];
70
- exports.HEROES = ['Barbarian King', 'Archer Queen', 'Grand Warden', 'Royal Champion', 'Battle Machine'];
71
- exports.HERO_PETS = ['L.A.S.S.I', 'Electro Owl', 'Mighty Yak', 'Unicorn'];
72
- exports.UNRANKED_LEAGUE_DATA = {
70
+ exports.Heroes = ['Barbarian King', 'Archer Queen', 'Grand Warden', 'Royal Champion', 'Battle Machine'];
71
+ exports.HeroPets = ['L.A.S.S.I', 'Electro Owl', 'Mighty Yak', 'Unicorn'];
72
+ exports.UnrankedLeagueData = {
73
73
  id: 29000000,
74
74
  name: 'Unranked',
75
75
  iconUrls: {
@@ -77,8 +77,8 @@ exports.UNRANKED_LEAGUE_DATA = {
77
77
  tiny: 'https://api-assets.clashofclans.com/leagues/36/e--YMyIexEQQhE4imLoJcwhYn6Uy8KqlgyY3_kFV6t4.png'
78
78
  }
79
79
  };
80
- exports.LEGEND_LEAGUE_ID = 29000022;
81
- exports.LEAGUES = [
80
+ exports.LegendLeagueId = 29000022;
81
+ exports.Leagues = [
82
82
  29000000,
83
83
  29000001,
84
84
  29000002,
@@ -101,13 +101,13 @@ exports.LEAGUES = [
101
101
  29000019,
102
102
  29000020,
103
103
  29000021,
104
- exports.LEGEND_LEAGUE_ID
104
+ exports.LegendLeagueId
105
105
  ];
106
- exports.WAR_LEAGUES = [
106
+ exports.WarLeagues = [
107
107
  48000000, 48000001, 48000002, 48000003, 48000004, 48000005, 48000006, 48000007, 48000008, 48000009, 48000010, 48000011, 48000012,
108
108
  48000013, 48000014, 48000015, 48000016, 48000017, 48000018
109
109
  ];
110
- exports.FRIENDLY_WAR_PREPARATION_TIMES = [
110
+ exports.FriendlyWarPreparationTimes = [
111
111
  1000 * 60 * 60 * 24,
112
112
  1000 * 60 * 60 * 20,
113
113
  1000 * 60 * 60 * 16,
@@ -121,25 +121,29 @@ exports.FRIENDLY_WAR_PREPARATION_TIMES = [
121
121
  1000 * 60 * 15,
122
122
  1000 * 60 * 5
123
123
  ];
124
- exports.EVENTS = {
125
- NEW_SEASON_START: 'newSeasonStart',
126
- CLAN_LOOP_START: 'clanLoopStart',
127
- CLAN_LOOP_END: 'clanLoopEnd',
128
- PLAYER_LOOP_START: 'playerLoopStart',
129
- PLAYER_LOOP_END: 'playerLoopEnd',
130
- WAR_LOOP_START: 'warLoopEnd',
131
- WAR_LOOP_END: 'warLoopEnd',
132
- MAINTENANCE_START: 'maintenanceStart',
133
- MAINTENANCE_END: 'maintenanceEnd',
134
- ERROR: 'error',
135
- DEBUG: 'debug'
124
+ exports.PollingEvents = {
125
+ NewSeasonStart: 'newSeasonStart',
126
+ ClanLoopStart: 'clanLoopStart',
127
+ ClanLoopEnd: 'clanLoopEnd',
128
+ PlayerLoopStart: 'playerLoopStart',
129
+ PlayerLoopEnd: 'playerLoopEnd',
130
+ WarLoopStart: 'warLoopEnd',
131
+ WarLoopEnd: 'warLoopEnd',
132
+ MaintenanceStart: 'maintenanceStart',
133
+ MaintenanceEnd: 'maintenanceEnd',
134
+ Error: 'error',
135
+ Debug: 'debug'
136
136
  };
137
- exports.CWL_ROUNDS = {
138
- PREVIOUS_ROUND: 'warEnded',
139
- CURRENT_ROUND: 'inWar',
140
- NEXT_ROUND: 'preparation'
137
+ exports.RestEvents = {
138
+ Error: 'error',
139
+ Debug: 'debug'
141
140
  };
142
- exports.RAW_DATA = {
143
- RAW_UNITS: raw_json_1.default.RAW_UNITS,
144
- RAW_SUPER_UNITS: raw_json_1.default.RAW_SUPER_UNITS
141
+ exports.CWLRounds = {
142
+ PreviousRound: 'warEnded',
143
+ CurrentRound: 'inWar',
144
+ NextRound: 'preparation'
145
+ };
146
+ exports.RawData = {
147
+ RawUnits: raw_json_1.default.RAW_UNITS,
148
+ RawSuperUnits: raw_json_1.default.RAW_SUPER_UNITS
145
149
  };
package/dist/util/Util.js CHANGED
@@ -114,8 +114,8 @@ class Util extends null {
114
114
  }
115
115
  /** Parse in-game army link into troops and spells count with respective Id's. */
116
116
  static parseArmyLink(link) {
117
- const unitsMatches = link.match(/u(?<units>[\d+x-]+)/);
118
- const spellsMatches = link.match(/s(?<spells>[\d+x-]+)/);
117
+ const unitsMatches = /u(?<units>[\d+x-]+)/.exec(link);
118
+ const spellsMatches = /s(?<spells>[\d+x-]+)/.exec(link);
119
119
  const unitsPart = unitsMatches?.groups?.unit?.split('-') ?? [];
120
120
  const spellParts = spellsMatches?.groups?.spells?.split('-') ?? [];
121
121
  const units = unitsPart
@@ -132,11 +132,11 @@ class Util extends null {
132
132
  }));
133
133
  return {
134
134
  units: units.map((unit) => {
135
- const _unit = Constants_1.RAW_DATA.RAW_UNITS.find((raw) => raw.category === 'troop' && raw.id === unit.id);
135
+ const _unit = Constants_1.RawData.RawUnits.find((raw) => raw.category === 'troop' && raw.id === unit.id);
136
136
  return { name: _unit?.name ?? null, count: unit.total, id: unit.id };
137
137
  }),
138
138
  spells: spells.map((spell) => {
139
- const _spell = Constants_1.RAW_DATA.RAW_UNITS.find((raw) => raw.category === 'spell' && raw.id === spell.id);
139
+ const _spell = Constants_1.RawData.RawUnits.find((raw) => raw.category === 'spell' && raw.id === spell.id);
140
140
  return { name: _spell?.name ?? null, count: spell.total, id: spell.id };
141
141
  })
142
142
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clashofclans.js",
3
- "version": "2.8.4",
3
+ "version": "3.0.0-dev.f6ce42f",
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",
@@ -34,61 +34,6 @@
34
34
  "url": "https://github.com/clashperk/clashofclans.js/issues"
35
35
  },
36
36
  "homepage": "https://clashofclans.js.org",
37
- "eslintConfig": {
38
- "extends": [
39
- "marine/prettier/node",
40
- "plugin:prettier/recommended"
41
- ],
42
- "plugins": [
43
- "prettier"
44
- ],
45
- "ignorePatterns": [
46
- "dist/*",
47
- "docs/*"
48
- ],
49
- "parser": "@typescript-eslint/parser",
50
- "rules": {
51
- "no-process-env": 0,
52
- "no-inline-comments": 0,
53
- "no-warning-comments": 0,
54
- "comma-dangle": [
55
- "error",
56
- "never"
57
- ],
58
- "@typescript-eslint/naming-convention": 0,
59
- "@typescript-eslint/no-floating-promises": 0,
60
- "@typescript-eslint/no-misused-promises": 0
61
- }
62
- },
63
- "prettier": {
64
- "semi": true,
65
- "tabWidth": 4,
66
- "printWidth": 140,
67
- "singleQuote": true,
68
- "quoteProps": "consistent",
69
- "bracketSpacing": true,
70
- "trailingComma": "none",
71
- "overrides": [
72
- {
73
- "files": [
74
- "*.md"
75
- ],
76
- "options": {
77
- "useTabs": false,
78
- "tabWidth": 4
79
- }
80
- },
81
- {
82
- "files": [
83
- "*.yml"
84
- ],
85
- "options": {
86
- "useTabs": false,
87
- "tabWidth": 2
88
- }
89
- }
90
- ]
91
- },
92
37
  "standard-version": {
93
38
  "skip": {
94
39
  "changelog": false,
@@ -100,18 +45,20 @@
100
45
  "node-fetch": "^2.6.7"
101
46
  },
102
47
  "devDependencies": {
103
- "@types/node": "^16.10.3",
104
48
  "@types/node-fetch": "^2.5.12",
49
+ "gen-esm-wrapper": "^1.1.3",
50
+ "@types/node": "^18.6.4",
105
51
  "@typescript-eslint/eslint-plugin": "^5.4.0",
106
52
  "@typescript-eslint/parser": "^5.4.0",
53
+ "dotenv": "^16.0.2",
107
54
  "eslint": "^8.3.0",
108
55
  "eslint-config-marine": "^9.0.6",
109
56
  "eslint-config-prettier": "^8.3.0",
57
+ "eslint-plugin-import": "^2.26.0",
110
58
  "eslint-plugin-prettier": "^4.0.0",
111
- "gen-esm-wrapper": "^1.1.3",
112
59
  "prettier": "^2.4.1",
113
60
  "rimraf": "^3.0.2",
114
- "typescript": "^4.5.2"
61
+ "typescript": "^4.7.4"
115
62
  },
116
63
  "engines": {
117
64
  "node": ">=14.x"
@@ -1,86 +0,0 @@
1
- import { Clan, ClanWar, Player } from '../struct';
2
- import { Client } from './Client';
3
- /** Represents Event Manager of the {@link Client}. */
4
- export declare class EventManager {
5
- private readonly client;
6
- private readonly _clanTags;
7
- private readonly _playerTags;
8
- private readonly _warTags;
9
- private readonly _clans;
10
- private readonly _players;
11
- private readonly _wars;
12
- private readonly _events;
13
- private _inMaintenance;
14
- private _maintenanceStartTime;
15
- constructor(client: Client);
16
- /** Initialize the Event Manager to start pulling. */
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;
30
- /**
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.
34
- *
35
- * @example
36
- * ```js
37
- * client.events.addClans(['#2PP', '#8QU8J9LP']);
38
- *
39
- * client.events.setClanEvent({
40
- * name: 'clanMemberUpdate',
41
- * filter: (oldClan, newClan) => {
42
- * return oldClan.memberCount !== newClan.memberCount;
43
- * }
44
- * });
45
- *
46
- * client.on('clanMemberUpdate', (oldClan, newClan) => {
47
- * console.log(oldClan.memberCount, newClan.memberCount);
48
- * });
49
- *
50
- * (async function () {
51
- * await client.events.init();
52
- * })();
53
- * ```
54
- * @returns
55
- */
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: {
75
- name: string;
76
- filter: (oldPlayer: Player, newPlayer: Player) => boolean;
77
- }): this;
78
- private maintenanceHandler;
79
- private seasonEndHandler;
80
- private clanUpdateHandler;
81
- private playerUpdateHandler;
82
- private warUpdateHandler;
83
- private runClanUpdate;
84
- private runPlayerUpdate;
85
- private runWarUpdate;
86
- }