De-pres Posted January 3, 2023 Report Posted January 3, 2023 const manager = new TradeOfferManager ({ steam: client, community: community, language: 'en' }); function make_trade(partner, sellingit, item){ // {"name":"","amount":0,"price":{"ref":0,"keys":0}} const offer = manager.createOffer(partner); function test(sellinv){ var sell_added = 0 for(var c=0; c<=sellinv.length-1; c++){ if(sellinv[c].market_name == item.name && sell_added < item.amount && sellinv[c].tradable == true){ seller_add(sellinv[c]) sell_added+=1; } } offer.send((err, status) => { if (err) { console.log(err); } else { console.log(`Sent offer. Status: ${status}.`); client.chatMessage(partner, `The offer is ${status}`) } }); } var buyer_add = offer.addTheirItem manager.getUserInventoryContents(partner, appid, contextid, true, (err, inv) => {}) var seller_add = offer.addMyItem manager.getInventoryContents(appid, contextid, true, (err, inv) =>{test(inv)}) } I dont know if i am doing it right or its just tradeoffer manager, when changed seller_add() at test function to offer.addMyItem Works fine error C:\Users\HP\Desktop\temp\server\main_bot\node_modules\steam-tradeoffer-manager\lib\classes\TradeOffer.js:167 return addItem(item, this, this.itemsToGive); ^ TypeError: Cannot read properties of undefined (reading 'itemsToGive') at TradeOffer.addMyItem (C:\Users\HP\Desktop\temp\server\main_bot\node_modules\steam-tradeoffer-manager\lib\classes\TradeOffer.js:167:34) at test (C:\Users\HP\Desktop\temp\server\main_bot\bot.js:185:11) at C:\Users\HP\Desktop\temp\server\main_bot\bot.js:205:72 at SteamCommunity.<anonymous> (C:\Users\HP\Desktop\temp\server\main_bot\node_modules\steamcommunity\components\users.js:591:5) at Request._callback (C:\Users\HP\Desktop\temp\server\main_bot\node_modules\steamcommunity\components\http.js:67:15) at Request.self.callback (C:\Users\HP\Desktop\temp\server\main_bot\node_modules\request\request.js:185:22) at Request.emit (node:events:513:28) at Request.<anonymous> (C:\Users\HP\Desktop\temp\server\main_bot\node_modules\request\request.js:1154:10) at Request.emit (node:events:513:28) at Gunzip.<anonymous> (C:\Users\HP\Desktop\temp\server\main_bot\node_modules\request\request.js:1076:12) Quote
Dr. McKay Posted January 3, 2023 Report Posted January 3, 2023 This is a JavaScript quirk. You need to do var buyer_add = offer.addTheirItem.bind(offer) De-pres 1 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.