seishun / node-steam-trade

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

Why does item come up as undefined? #75

Closed rycao18 closed 8 years ago

rycao18 commented 8 years ago

So I'm attempting to create a trade bot, and I've stumbled upon a little error. Here's the part of the code that i'm wondering about

client.on("tradeRequest", function(steamID, respond) {
    console.log("Incoming Trade Request from " + steamID.getSteam3RenderedID());
    respond(true);
})

client.on("tradeStarted", function(steamID) {
    steamTrade.open(JSON.stringify(steamID));
})

steamTrade.on('offerChanged', function(added, item) {
    console.log('they ' + (added ? 'added ' : 'removed '));
    console.log(item);
    for(var i = 0; i < steamTrade.themAssets.length; i++) {
        console.log(steamTrade.themAssets[i]);
    }
});

I get this error as soon as I add an item in the trade (the trade opens up fine)

C:\Users\Richard\Desktop\Steam\NodeJS\GlitchedTurtleBot\node_modules\steam-trade\index.js:208
      return self._themInventories[item.appid][item.contextid][item.assetid];
                                              ^

TypeError: Cannot read property '2' of undefined
    at C:\Users\Richard\Desktop\Steam\NodeJS\GlitchedTurtleBot\node_modules\steam-trade\index.js:208:47
    at Array.map (native)
    at SteamTrade._onTradeStatusUpdate (C:\Users\Richard\Desktop\Steam\NodeJS\GlitchedTurtleBot\node_modules\steam-trade\index.js:206:72)
    at Request._callback (C:\Users\Richard\Desktop\Steam\NodeJS\GlitchedTurtleBot\node_modules\steam-trade\index.js:244:10)
    at Request.self.callback (C:\Users\Richard\Desktop\Steam\NodeJS\GlitchedTurtleBot\node_modules\steam-trade\node_modules\request\request.js:187:22)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (C:\Users\Richard\Desktop\Steam\NodeJS\GlitchedTurtleBot\node_modules\steam-trade\node_modules\request\request.js:1044:10)
    at emitOne (events.js:77:13)
    at Request.emit (events.js:169:7)

I was wondering why this item is "undefined" and how I can go about making the bot recognize the item?

seishun commented 8 years ago

It seems you're using steam-user. See here.

rycao18 commented 8 years ago

@seishun I though I did convert the steamID to a string?

rycao18 commented 8 years ago

I'm actually terrible at coding. Please kill me

chrom007 commented 8 years ago

@rycao18 String(steamID)