lunar Posted December 6, 2018 Report Posted December 6, 2018 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.com/package/steam-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); } Quote
Dr. McKay Posted December 6, 2018 Report Posted December 6, 2018 The code that's an issue is not in your paste. Quote
lunar Posted December 8, 2018 Author Report Posted December 8, 2018 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. Quote
lunar Posted December 8, 2018 Author Report Posted December 8, 2018 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!"); } }); } }); }); }} Quote
Dr. McKay Posted December 9, 2018 Report Posted December 9, 2018 You're missing the tradableOnly param in manager.getInventoryContents. Quote
lunar Posted December 9, 2018 Author Report Posted December 9, 2018 oooh haha thanks, i'll add it now Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.