PlanZed Posted May 11, 2020 Report Posted May 11, 2020 I am currently creating a TF2 trading bot and I want it to be able to send trade offers but i keep getting this error C:\Users\Valkyrie\Desktop\Trading Bot\node_modules\steamcommunity\components\users.js:491 callback(null, inventory, currency, body.total_inventory_count); My main code is client.on("friendMessage", function(steamID, message) { if (message == "!buy test item") { client.chatMessage(steamID, "Setting up the trade offer for Test Item"); console.log("Someone typed in the command '!buy test item'"); const offer = manager.createOffer(steamID); manager.loadInventory(440, 2, true, (err, inventory) => { if (err) { client.chatMessage("There was an error loading the inventory. Please try again. If the problem continues please message the owner by typing '!help'"); console.log(err); console.log("There was an error loading my inventory."); } else { offer.getPartnerInventoryContents(440, 2, true, (err, inventory) => { if (err) { client.chatMessage("There was an error loading the inventory. Please try again. If the problem continues please message the owner by typing '!help'"); console.log(err); console.log("There was an error loading their inventory."); } else { const offer = manager.createOffer(76561198083465811); inventory.forEach(function(item) { if (item.assetid === '30362') { offer.addMyItem(item); offer.addTheirItems(5002, 5002, 5001, 5001, 5000, 5000); offer.setMessage("1 Law for 2.88 Refined"); offer.send(function(err, status) { if (err) { client.chatMessage("There was an error sending the trade offer. Please try again. If the problem continues please message the owner by typing '!help'"); console.log(err); console.log("There was an error sending the trade offer."); } else { console.log(status); console.log("The trade was sent successfully!"); } }) } }) } }) } }) } }) Quote
Dr. McKay Posted May 11, 2020 Report Posted May 11, 2020 You've cut out the actual error message. Quote
PlanZed Posted May 11, 2020 Author Report Posted May 11, 2020 1 hour ago, Dr. McKay said: You've cut out the actual error message. C:\Users\Valkyrie\Desktop\Trading Bot\node_modules\steamcommunity\components\users.js:491 callback(null, inventory, currency, body.total_inventory_count); ^ TypeError: callback is not a function at SteamCommunity.<anonymous> (C:\Users\Valkyrie\Desktop\Trading Bot\node_modules\steamcommunity\components\users.js:491:5) at Request._callback (C:\Users\Valkyrie\Desktop\Trading Bot\node_modules\steamcommunity\components\http.js:67:15) at Request.self.callback (C:\Users\Valkyrie\Desktop\Trading Bot\node_modules\request\request.js:185:22) at Request.emit (events.js:310:20) at Request.<anonymous> (C:\Users\Valkyrie\Desktop\Trading Bot\node_modules\request\request.js:1154:10) at Request.emit (events.js:310:20) at Gunzip.<anonymous> (C:\Users\Valkyrie\Desktop\Trading Bot\node_modules\request\request.js:1076:12) at Object.onceWrapper (events.js:416:28) at Gunzip.emit (events.js:322:22) at endReadableNT (_stream_readable.js:1187:12) Quote
Perport Posted May 11, 2020 Report Posted May 11, 2020 (edited) You defined offer variable twice in your code as constant please fix that. And for your problem offer.getPartnerInventoryContents(440, 2, (err, inventory,currency) => { } this should fix it yours has 4 inputs for some reason. Edited May 11, 2020 by Perport Quote
xLeeJYx Posted May 14, 2020 Report Posted May 14, 2020 On 5/12/2020 at 1:52 AM, Perport said: You defined offer variable twice in your code as constant please fix that. And for your problem offer.getPartnerInventoryContents(440, 2, (err, inventory,currency) => { } this should fix it yours has 4 inputs for some reason. This is a problem and another problem is you are using the same name for loading both inventories. `loadInventory` and `getPartnerInventoryContents` both are using the same callback name `inventory`. This is making the code break 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.