Jump to content


Photo

TypeError: Callback is not a function

node.js node-steamcommunity

  • Please log in to reply
5 replies to this topic

#1 lunar

lunar

    Member

  • Member
  • PipPip
  • 10 posts

Posted 06 December 2018 - 07:48 AM

i'm getting the callback is not a function in the steamcommunity/user.js:484 file I have no idea what line of code of mine is causing this, I am trying to make a level bot and get all the sets in our inventory and add as many sets until the amount is reached which is the buyRate * how many keys the user wants to use.

 

error 

D:\Documents\Google Drive\Node\SteamBot\node_modules\steamcommunity\components\users.js:484
                                callback(null, inventory, currency, body.total_inventory_count);
                                ^

TypeError: callback is not a function
    at SteamCommunity.<anonymous> (D:\Documents\Google Drive\Node\SteamBot\node_modules\steamcommunity\components\users.js:484:5)
    at Request._callback (D:\Documents\Google Drive\Node\SteamBot\node_modules\steamcommunity\components\http.js:67:15)
    at Request.self.callback (D:\Documents\Google Drive\Node\SteamBot\node_modules\request\request.js:185:22)
    at Request.emit (events.js:182:13)
    at Request.<anonymous> (D:\Documents\Google Drive\Node\SteamBot\node_modules\request\request.js:1161:10)
    at Request.emit (events.js:182:13)
    at IncomingMessage.<anonymous> (D:\Documents\Google Drive\Node\SteamBot\node_modules\request\request.js:1083:12)
    at Object.onceWrapper (events.js:273:13)
    at IncomingMessage.emit (events.js:187:15)
    at endReadableNT (_stream_readable.js:1086:12)

and here is the code that is possibly causing the error ( I am also using https://www.npmjs.co...m-market-search for the market search as I couldn't get the one in steamcommunity to work)

for(var i = 0; i < cardApps.length; ++i){ //Loop through all the appid's we have
					steamMarket.searchCommunity(cardApps[i]).then(function(item){ //searches steam market for the appid
						var itemCount = 0;
						var cards = [];
						for(var j = 0; j < item.length; ++j){ //loop through each item
							if(item[j].type.includes('Trading Card') && item[j].rarity.includes('Normal')){ //if they are a normal trading card
								++itemCount;
								var ata = 0;
								if(ata <= cardApps[i].amountToAdd){
									for (let y = 0; y < myItems.length; ++y) { //loop through all our items
										if(myItems[y].market_hash_name == myItems[j].hash_name){ //if our item matches the one we are currently looking at
											cards.push({id: myItems[y].id, appid: 753, contextid: 6}); // add to item array
											++ata;
										}
									}
								}
								
							}
							if(cards.length == itemCount){
								offer.addMyItems(cards);
								cardApps.splice(i, 1);
							}
						}
					}, console.error);
				}


#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,810 posts

Posted 06 December 2018 - 06:01 PM

The code that's an issue is not in your paste.



#3 lunar

lunar

    Member

  • Member
  • PipPip
  • 10 posts

Posted 08 December 2018 - 08:13 AM

I commented out everything to where it was working previously and it still gives me that console error, i even console.log everything and nothing is being logged in the console, just sends me a message on steam when it initiates the offer and then crashes with the error. 



#4 lunar

lunar

    Member

  • Member
  • PipPip
  • 10 posts

Posted 08 December 2018 - 08:19 AM

I commented out everything to where it was working previously and it still gives me that console error, i even console.log everything and nothing is being logged in the console, just sends me a message on steam when it initiates the offer and then crashes with the error. 

 

here is my entire buy function that gets called when you type "!buy number" into the bot

 

function buy(steamID, amount){
    if(isNaN(amount) || amount === undefined){
        client.chatMessage(steamID, "Please enter a valid number");
    }
    else{
        var keyCount = 0;
        var i = 0;
        client.chatMessage(steamID, "Creating Offer, please wait!");
        //Check Players inventory for the keys, and make sure we have enough sets to supply
        var offer = manager.createOffer(steamID);
        offer.setMessage("Price: " + amount + " Keys. Sets: " + amount * config.buyRate);
        console.log('offer created');

        manager.getInventoryContents(753, 6, function(err, myItems){
            if(err){
                console.log(err);
                return;
            }
            offer.getPartnerInventoryContents(440, 2, function(err, theirItems){
                if(err){
                    console.log(err);
                    return;
                }
                var keys = [];
                var cardApps = [];
                var totalBuying = 0;
                getBadge.get('GetBadges', 1, { steamid: steamID }, function(statusCode, response) {
                    console.log('Got Badges');
                    if(cardApps.length <= config.buyRate * amount){
                        console.log('app list is less than the buyrate');
                        for(var i = 0; i < myItems.length; ++i){ // loop through our inventory
                            console.log('going through items');
                            if(myItems[i].type.includes('Trading Card')){ // if the item is a trading card
                                console.log('we have a trading card');
                                var id = myItems[i].market_hash_name; //set id as the market hash name
                                id = id.replace(/[^0-9]/g,''); // remove the card name so we get app id
                                if(statusCode == 200){
                                    console.log('we found badges');
                                    for(var j = 0; j < response.response.badges.length; ++j){
                                        console.log('browsing badge');
                                        if(!cardApps.includes(id)){ // check if we don't already have it
                                        console.log('we dont have this appid already');
                                            if(response.response.badges[j].level < 5){
                                                var counter = 0;
                                                counter = 5 - response.response.badges[j].level;
                                                cardApps.push({app: id, amountToAdd: counter}); // add to array if we dont have it already
                                                console.log('added a specific amount of times');
                                            }
                                            else if(!response.response.badges[j].appid.includes(id)){
                                                cardApps.push({app: id, amountToAdd: 5});
                                                console.log('added 5 times');
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                });
                
                //Adding the Users Items
                for(var i = 0; i < theirItems.length; ++i){
                    if(theirItems[i].market_hash_name == config.keysAccepted && keys.length < amount){
                        console.log("Adding Their Item");
                        keys.push(theirItems[i].id);
                        offer.addTheirItem({id: theirItems[i].id, appid: 440, contextid: 2});
                        console.log("Length of keys "+keys.length);
                        console.log(keys);
                        ++keyCount;
                    }
                }
                //Adding our Items
                for(var i = 0; i < cardApps.length; ++i){ //Loop through all the appid's we have
                    console.log('going through the app id');
                    steamMarket.searchCommunity(cardApps[i]).then(function(item){ //searches steam market for the appid
                        console.log('searched the market for the app id');
                        var itemCount = 0;
                        var cards = [];
                        for(var j = 0; j < item.length; ++j){ //loop through each item
                            console.log('going through items on market');
                            if(item[j].type.includes('Trading Card') && item[j].rarity.includes('Normal')){ //if they are a normal trading card
                                console.log('going through items on market');
                                ++itemCount;
                                var ata = 0;
                                if(ata <= cardApps[i].amountToAdd){
                                    console.log('going through the amount of sets we need to add');
                                    for (let y = 0; y < myItems.length; ++y) { //loop through all our items
                                        console.log('for our items look through em');
                                        if(myItems[y].market_hash_name == myItems[j].hash_name){ //if our item matches the one we are currently looking at
                                            console.log('we have a matching item');
                                            cards.push({id: myItems[y].id, appid: 753, contextid: 6}); // add to item array
                                            ++ata;
                                            console.log('added the item to list');
                                        }
                                    }
                                }
                                
                            }
                            if(cards.length == itemCount){
                                console.log('added to our offer');
                                offer.addMyItems(cards);
                                cardApps.splice(i, 1);
                                console.log('removed the card app from the list.');
                            }
                        }
                    }, console.error);
                }
                if(keyCount < amount){
                    console.log("count: "+keyCount);
                    client.chatMessage(steamID, "You don't have enough keys for me to send this trade.");
                    return;
                }
                else if(totalBuying < (amount * config.buyRate)){
                    console.log("card sets: " + totalBuying);
                    client.chatMessage(steamID, "I currently do not have enough card sets to trade you.");
                    return;
                }
                else{
                    offer.send(function(err, status){
                        if(err){
                            console.log(err);
                            client.chatMessage(steamID, "An Error has Occured while sending offer.");
                        }
                        if(status == "pending"){
                            client.chatMessage(steamID, "Confirming Offer!");
                        }
                        if(status == "sent"){
                            client.chatMessage(steamID, "Offer Sent!");
                        }
                    });
                }
            });
        });
        
        
        
        
    }
}


#5 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,810 posts

Posted 08 December 2018 - 07:01 PM

You're missing the tradableOnly param in manager.getInventoryContents.



#6 lunar

lunar

    Member

  • Member
  • PipPip
  • 10 posts

Posted Yesterday, 01:34 AM

oooh haha thanks, i'll add it now







Also tagged with one or more of these keywords: node.js, node-steamcommunity

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users