clashperk / clashofclans.js

JavaScript library for interacting with the Clash of Clans API
https://clashofclans.js.org/
MIT License
54 stars 23 forks source link

Error with getPlayer() #168

Closed Lajoie25 closed 7 months ago

Lajoie25 commented 7 months ago

Error when call getPlayer() with players below HT 10:

\CocTeams\node_modules\clashofclans.js\dist\struct\Unit.js:32 this.level = origin.level; ^

TypeError: Cannot read properties of undefined (reading 'level')

in rawSuperUnit, I debug with this code to continue my app:

        if (origin) {
            this.level = origin.level;
            this.maxLevel = origin.maxLevel;
            this.boostable = data.townHallLevel >= 11 && origin.level >= rawSuperUnit.minOriginalLevel;
            this.upgradeCost = original.upgrade.cost[origin.level - 1] || 0;
            this.upgradeResource = original.upgrade.resource;
            this.upgradeTime = original.upgrade.time[origin.level - 1] || 0;
        }
csuvajit commented 7 months ago

Fixed

dannycreations commented 7 months ago

@csuvajit This is not fixed, you can check with this #Q9QRCUGU9

Barbarian { name: 'Barbarian', level: 6, maxLevel: 12, village: 'home' }
Archer { name: 'Archer', level: 8, maxLevel: 12, village: 'home' }
Wall Breaker { name: 'Wall Breaker', level: 4, maxLevel: 12, village: 'home' }
Giant { name: 'Giant', level: 4, maxLevel: 12, village: 'home' }
Goblin { name: 'Goblin', level: 4, maxLevel: 9, village: 'home' }
Miner { name: 'Miner', level: 1, maxLevel: 10, village: 'home' }
Balloon { name: 'Balloon', level: 8, maxLevel: 11, village: 'home' }
Baby Dragon { name: 'Baby Dragon', level: 1, maxLevel: 10, village: 'home' }
Valkyrie { name: 'Valkyrie', level: 1, maxLevel: 11, village: 'home' }
Witch { name: 'Witch', level: 4, maxLevel: 7, village: 'home' }
Lava Hound { name: 'Lava Hound', level: 1, maxLevel: 6, village: 'home' }
Bowler undefined
csuvajit commented 7 months ago

I see, fixed again.

dannycreations commented 7 months ago

fixed, thanks @csuvajit