clashofclans.js 3.3.0-dev.2775232 → 3.3.0-dev.8b4dbb1
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/README.md +24 -34
- package/dist/client/PollingClient.d.ts +3 -0
- package/dist/client/PollingClient.js +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,62 +11,52 @@
|
|
|
11
11
|
|
|
12
12
|
### Installation
|
|
13
13
|
|
|
14
|
-
-
|
|
15
|
-
-
|
|
14
|
+
- **`npm i clashofclans.js`**
|
|
15
|
+
- **Node.js v16 or newer is required.**
|
|
16
16
|
|
|
17
17
|
### Links
|
|
18
18
|
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
19
|
+
- [Documentation](https://clashofclans.js.org/docs/)
|
|
20
|
+
- [Clash of Clans Developer Website](https://developer.clashofclans.com/)
|
|
21
|
+
- [Clash of Clans API Community Discord](https://discord.gg/Eaja7gJ)
|
|
22
22
|
|
|
23
23
|
### Examples
|
|
24
24
|
|
|
25
25
|
```js
|
|
26
26
|
const { Client } = require('clashofclans.js');
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
#### Login with Email Password
|
|
30
|
+
|
|
31
|
+
```js
|
|
27
32
|
const client = new Client();
|
|
28
|
-
// const client = new Client({ keys: [], cache: true, retryLimit: 2, restRequestTimeout: 5000 });
|
|
29
33
|
|
|
30
34
|
(async function () {
|
|
31
|
-
|
|
35
|
+
// This method should be called once when application starts.
|
|
36
|
+
await client.login({ email: 'developer@email.com', password: '***' });
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
const clan = await client.getClan('#2PP');
|
|
39
|
+
console.log(`${clan.name} (${clan.tag})`);
|
|
35
40
|
})();
|
|
36
41
|
```
|
|
37
42
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
> **Warning** <br />
|
|
41
|
-
> Events are neither real-time nor supported by the API. They are polled frequently and compared with the cached data. If there is a difference, the event is emitted.
|
|
43
|
+
#### Login with API Keys
|
|
42
44
|
|
|
43
45
|
```js
|
|
44
|
-
const
|
|
45
|
-
const pollingClient = new PollingClient({
|
|
46
|
-
cache: true,
|
|
47
|
-
retryLimit: 1,
|
|
48
|
-
restRequestTimeout: 5000,
|
|
49
|
-
throttler: new BatchThrottler(20)
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
pollingClient.addClans(['#8QU8J9LP', '#8P2QG08P']);
|
|
53
|
-
pollingClient.setClanEvent({
|
|
54
|
-
name: 'clanDescriptionChange',
|
|
55
|
-
filter: (oldClan, newClan) => {
|
|
56
|
-
return oldClan.description !== newClan.description;
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
pollingClient.on('clanDescriptionChange', (oldClan, newClan) => {
|
|
61
|
-
console.log(oldClan.description, newClan.description);
|
|
62
|
-
});
|
|
46
|
+
const client = new Client({ keys: ['api_key_goes_here'] });
|
|
63
47
|
|
|
64
48
|
(async function () {
|
|
65
|
-
|
|
66
|
-
|
|
49
|
+
const clan = await client.getClan('#2PP');
|
|
50
|
+
console.log(`${clan.name} (${clan.tag})`);
|
|
67
51
|
})();
|
|
68
52
|
```
|
|
69
53
|
|
|
54
|
+
### Events
|
|
55
|
+
|
|
56
|
+
The API lacks socket-based real-time events. It is recommended to implement your own custom polling system.
|
|
57
|
+
Pull data at specified intervals, compare with previous values, and emit events on change.
|
|
58
|
+
Consider using Node.js clusters and threads for efficient parallel processing.
|
|
59
|
+
|
|
70
60
|
### Disclaimer
|
|
71
61
|
|
|
72
62
|
> This content is not affiliated with, endorsed, sponsored, or specifically approved by Supercell and Supercell is not responsible for it. For more information see [Supercell's Fan Content Policy](https://supercell.com/en/fan-content-policy/).
|
|
@@ -8,6 +8,9 @@ import { Client } from './Client';
|
|
|
8
8
|
* const { PollingClient } = require('clashofclans.js');
|
|
9
9
|
* const pollingClient = new PollingClient({ keys: ['***'] });
|
|
10
10
|
* ```
|
|
11
|
+
* @deprecated The API lacks socket-based real-time events. It is recommended to implement your own custom polling system.
|
|
12
|
+
* Pull data at specified intervals, compare with previous values, and emit events on change.
|
|
13
|
+
* Consider using Node.js clusters for efficient parallel processing.
|
|
11
14
|
*/
|
|
12
15
|
export declare class PollingClient extends Client {
|
|
13
16
|
private readonly _clanTags;
|
|
@@ -10,6 +10,9 @@ const Client_1 = require("./Client");
|
|
|
10
10
|
* const { PollingClient } = require('clashofclans.js');
|
|
11
11
|
* const pollingClient = new PollingClient({ keys: ['***'] });
|
|
12
12
|
* ```
|
|
13
|
+
* @deprecated The API lacks socket-based real-time events. It is recommended to implement your own custom polling system.
|
|
14
|
+
* Pull data at specified intervals, compare with previous values, and emit events on change.
|
|
15
|
+
* Consider using Node.js clusters for efficient parallel processing.
|
|
13
16
|
*/
|
|
14
17
|
class PollingClient extends Client_1.Client {
|
|
15
18
|
constructor(options) {
|
package/package.json
CHANGED