lunar
-
Posts
10 -
Joined
-
Last visited
Posts posted by lunar
-
-
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 supplyvar 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 inventoryconsole.log('going through items');if(myItems[i].type.includes('Trading Card')){ // if the item is a trading cardconsole.log('we have a trading card');var id = myItems[i].market_hash_name; //set id as the market hash nameid = id.replace(/[^0-9]/g,''); // remove the card name so we get app idif(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 itconsole.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 alreadyconsole.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 Itemsfor(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 Itemsfor(var i = 0; i < cardApps.length; ++i){ //Loop through all the appid's we haveconsole.log('going through the app id');steamMarket.searchCommunity(cardApps[i]).then(function(item){ //searches steam market for the appidconsole.log('searched the market for the app id');var itemCount = 0;var cards = [];for(var j = 0; j < item.length; ++j){ //loop through each itemconsole.log('going through items on market');if(item[j].type.includes('Trading Card') && item[j].rarity.includes('Normal')){ //if they are a normal trading cardconsole.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 itemsconsole.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 atconsole.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!");}});}});});}} -
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.
-
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); }
-
Got it working
var a = []; for(var i = 0; i < inventory.length; ++i){ if(inventory[i].market_hash_name == config.keysAccepted && a.length < amount){ console.log("Adding Item"); a.push(inventory[i].id); offer.addTheirItem({id: inventory[i].id, appid: 440, contextid: 2}); console.log("Length of a "+a.length); console.log(a); ++count; } }
-
I am trying to only get defined number of keys in a trade, but instead it adds all the items as they share the same id (item is a TF2 Mann co. key)
here is my current code for the trade offer, (the steam id in create offer is a mates steamid as I can't test with my own account due to vac)
function buy(steamID, amount){ if(isNaN(amount) || amount === undefined){ client.chatMessage(steamID, "Please enter a valid number"); } else{ var count = 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('76561198008100070'); offer.setMessage("Price: " + amount + " Keys. Sets: " + amount * config.buyRate); offer.getPartnerInventoryContents(440, 2, function(err, inventory, currencies){ if(err){ console.log(err); } /*for (var j = 0; j < amount; ++j){ if(inventory[i].market_hash_name == config.keysAccepted){ ++count; console.log("Adding Item"); offer.addTheirItem({id: inventory[i].id, appid: 440, contextid: 2}); } }*/ inventory.forEach(function(val){ if(val.market_hash_name == config.keysAccepted){ console.log("Adding Item"); offer.addTheirItem({id: val.instanceid, appid: 440, contextid: 2}); ++count; } }); if(count < amount){ console.log("count: "+count); client.chatMessage(steamID, "You don't have enough keys for me to send this trade."); } 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!"); } }); } }); } }
-
I'm having trouble getting the element from the json in the response.
do I get the element I want via response.elementIWantHere or response[elementIWantHere]?as I have tried both and neither work.
This is my code so far.
api.get("IPlayerService", "GetBadges", 1, steamid=steamID, function(err, response){if(err){console.log(err);}console.log("level: " + results[steamID] + " xp: " + response.player_xp);client.chatMessage(steamID, "You have " + response.player_xp + " xp and are level " + level);});Response currently just gives me undefined as the value
and I get a internal server error
edit: Ended up using seishun's node-steam-web-api for it as it worked first try.
-
it's the segment after the badges array https://api.steampowered.com/IPlayerService/GetBadges/v1/
{"response":{"badges":[{badges go in here}],"player_xp":xp here,"player_level": level,"player_xp_needed_to_level_up":xp needed for next level,"player_xp_needed_current_level":xp needed for current level}
-
thanks, i'll have a look into it through that.
-
i am trying to get the current xp of a user and the xp required to achieve a level but i don't know how to see how much xp they currently have? is there something built into steam-user or should i use another module?
here is my code for the command
function level(steamID, level){client.getSteamLevels([steamID], function(results){console.log("level: " + results[steamID] + "xp: " + results[steamID].xp); // just gives me undefined for the result for xpif(level === undefined){level = results[steamID];}if(level >= results[steamID]){client.chatMessage(steamID, "You would need " + /*xp required here*/ + "more xp for level " + level);}else{client.chatMessage(steamID, "Please enter a higher number");}});}
TypeError: Callback is not a function
in node-steamcommunity
Posted
oooh haha thanks, i'll add it now