seishun / node-steam-trade

Node.js wrapper around Steam trading
162 stars 36 forks source link

TypeError: Cannot call method 'filter' of undefined #51

Closed pranaymk closed 9 years ago

pranaymk commented 9 years ago

Every now and then the bot comes into the error "TypeError: Cannot call method 'filter' of undefined" when trying to filter it's inventory. I can't seem to find the issue.

http://i.imgur.com/GqCoSxz.png

var scrap;
var rec;
var ref;

steam.on('sessionStart', function(otherClient) {
    scrap = [];
    rec = [];
    ref = [];
    steamTrade.open(otherClient);
    steamTrade.loadInventory(440, 2, function(inv) {
        scrap = inv.filter(function(item) {return item.name == 'Scrap Metal';});
        rec = inv.filter(function(item) {return item.name == 'Reclaimed Metal';});
        ref = inv.filter(function(item) {return item.name == 'Refined Metal';});
    });
});

Here is the code, I've removed anything that wasn't necessary.

I've tried to debug with no luck, and believe I've handled everything correctly and not made any errors in the code.