npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

clashofclans-events

v1.0.7

Published

A Simple JavaScript Clash Of Clan Event based library that tracks Donation, Player Join and Left, Clan Activities.

Downloads

14

Readme

Status License


Installation

You can install clashofclans-events using npm:

npm install clashofclans-events

Step 1: Configuration

There are 2 arguments options and events, options : { ratelimit, tokens, sync } and events : { donationEvent, clanEvent, playerJoin, playerLeft, playerPromote, playerDemote }. Note: Set true only if events are required.

const Client = require('clashofclans-events');

const Coc = new Client({
    ratelimit: 10,  // default is 10 events/sec
    tokens: ['<token>'],
    sync: 120      // default sync of clans in seconds
}, {
    playerJoin: true,   // default all events are false
    playerLeft: true,
    donationEvent: true,
    clanEvent: true,
    playerPromote: true,
    playerDemote: true
});

Step 2: Initialization

Initialize the tracker by calling init() function and pass { Array.<string> } tags.

Coc.init(['<tag1>', '<tag2>', ...]);

You can Add/Delete clans from/to tracker.

// Add a clan
Coc.add('<tag>');

// Delete a clan
Coc.delete('<tag>');

Step 3: Listeners/Events

List of Events

'donationEvent'

This event listens to troops recieved and donated from players in clan.

Coc.on('donationEvent', (message) => {
    console.log(message); 
});

Output:

{ name: 'Indian Hounds',
  tag: '#V88CRPU',
  badgeUrls:
   { small:
      'https://api-assets.clashofclans.com/badges/70/oaygM0AU0VupNHITpoIcnWW9a6YMG-houO7GUmuYGlg.png',
     large:
      'https://api-assets.clashofclans.com/badges/512/oaygM0AU0VupNHITpoIcnWW9a6YMG-houO7GUmuYGlg.png',
     medium:
      'https://api-assets.clashofclans.com/badges/200/oaygM0AU0VupNHITpoIcnWW9a6YMG-houO7GUmuYGlg.png' },
  members: 44,
  type: 'open',
  donated:
   [ { name: '♠️Shey_xoOR♠️',
       tag: '#GCG0LV90',
       troops: 20,
       league: [Object] },
     { name: 'merdo',
       tag: '#280RQ28UR',
       troops: 20,
       league: [Object] } ],
  received:
   [ { name: 'el solitario',
       tag: '#LCCPP8J9Y',
       troops: 50,
       league: [Object] },
     { name: 'rudra', tag: '#LLQQPJQJC', troops: 5, league: [Object] } ],
  mismatch: [ { troops: 5 } ] }

'clanEvent'

This event listens to Clan activities ie change of description, location, required trophies, clan level promote, clan entry, war frequecy, war-log visbility, war league, badge change.

eventType : descriptionChange, locationChange, requiredTrophiesChange, clanLevelChange, typeChange, warFrequencyChange, isWarLogPublicChange, warLeagueChange, badgeUrlsChange

Coc.on('clanEvent', (message) => {
    console.log(message); 
});

Output:

{ name: 'Indian Hounds',
  tag: '#V88CRPU',
  badgeUrls:
   { small:
      'https://api-assets.clashofclans.com/badges/70/oaygM0AU0VupNHITpoIcnWW9a6YMG-houO7GUmuYGlg.png',
     large:
      'https://api-assets.clashofclans.com/badges/512/oaygM0AU0VupNHITpoIcnWW9a6YMG-houO7GUmuYGlg.png',
     medium:
      'https://api-assets.clashofclans.com/badges/200/oaygM0AU0VupNHITpoIcnWW9a6YMG-houO7GUmuYGlg.png' },
  members: 44,
  type: 'open',
  eventType: 'requiredTrophiesChange',
  previous: 1000,
  current: 2000

'playerJoin' and 'playerLeft'

This event listens to player join/leave of clan.

Coc.on('playerJoin', (message) => {
    console.log(message); 
});

Coc.on('playerLeft', (message) => {
    console.log(message); 
});

Output:

{ clan:
   { name: 'Indian Hounds',
     tag: '#V88CRPU',
     badgeUrls:
      { small:
         'https://api-assets.clashofclans.com/badges/70/oaygM0AU0VupNHITpoIcnWW9a6YMG-houO7GUmuYGlg.png',
        large:
         'https://api-assets.clashofclans.com/badges/512/oaygM0AU0VupNHITpoIcnWW9a6YMG-houO7GUmuYGlg.png',
        medium:
         'https://api-assets.clashofclans.com/badges/200/oaygM0AU0VupNHITpoIcnWW9a6YMG-houO7GUmuYGlg.png' },
     members: 44,
     type: 'open' },
  tag: '#LQPYGVGPC',
  name: 'Grey Ninja',
  role: 'member',
  expLevel: 82,
  league:
   { id: 29000012,
     name: 'Crystal League I',
     iconUrls:
      { small:
         'https://api-assets.clashofclans.com/leagues/72/kSfTyNNVSvogX3dMvpFUTt72VW74w6vEsEFuuOV4osQ.png',
        tiny:
         'https://api-assets.clashofclans.com/leagues/36/kSfTyNNVSvogX3dMvpFUTt72VW74w6vEsEFuuOV4osQ.png',
        medium:
         'https://api-assets.clashofclans.com/leagues/288/kSfTyNNVSvogX3dMvpFUTt72VW74w6vEsEFuuOV4osQ.png' } },
  trophies: 2465,
  versusTrophies: 2068,
  clanRank: 15,
  previousClanRank: 0,
  donations: 0,
  donationsReceived: 0 }

'playerPromote' and 'playerDemote'

This event listens to player promotion/demotion of clan.

Coc.on('playerPromote', (message) => {
    console.log(message); 
});

Coc.on('playerDemote', (message) => {
    console.log(message); 
});

Output:

{ clan:
   { name: 'Indian Hounds',
     tag: '#V88CRPU',
     badgeUrls:
      { small:
         'https://api-assets.clashofclans.com/badges/70/oaygM0AU0VupNHITpoIcnWW9a6YMG-houO7GUmuYGlg.png',
        large:
         'https://api-assets.clashofclans.com/badges/512/oaygM0AU0VupNHITpoIcnWW9a6YMG-houO7GUmuYGlg.png',
        medium:
         'https://api-assets.clashofclans.com/badges/200/oaygM0AU0VupNHITpoIcnWW9a6YMG-houO7GUmuYGlg.png' },
     members: 44,
     type: 'open' },
  tag: '#LQPYGVGPC',
  name: 'Grey Ninja',
  role: 'member',
  expLevel: 82,
  league:
   { id: 29000012,
     name: 'Crystal League I',
     iconUrls:
      { small:
         'https://api-assets.clashofclans.com/leagues/72/kSfTyNNVSvogX3dMvpFUTt72VW74w6vEsEFuuOV4osQ.png',
        tiny:
         'https://api-assets.clashofclans.com/leagues/36/kSfTyNNVSvogX3dMvpFUTt72VW74w6vEsEFuuOV4osQ.png',
        medium:
         'https://api-assets.clashofclans.com/leagues/288/kSfTyNNVSvogX3dMvpFUTt72VW74w6vEsEFuuOV4osQ.png' } },
  trophies: 2465,
  versusTrophies: 2068,
  clanRank: 15,
  previousClanRank: 0,
  donations: 0,
  donationsReceived: 0,
  previous: 'coLeader',
  current: 'admin' }

'error'

This event listens to any error that occurs on API request ie Maintainance Break, Invalid Token, Invalid Tag etc.,

Coc.on('error', (message) => {
    console.log(message); 
});

Output:

{ tag: 'GGQ2UYJL', statusCode: 403, statusMessage: 'Forbidden' }