EnelGy Posted November 30, 2020 Report Posted November 30, 2020 (edited) I really dont know how is that possible... Earlier I have set offer.data('cancelTime', 120000); and after first succesfully completed trade, I was keeping getting this...the offer.state "Canceled" (all the time I restart my bot, first trade works, others it cancels) manager.getUserInventoryContents(offer.partner.getSteamID64(), 440, 2, true, function (err, myInv){ if (err) { console.log(err); } else { // I need to send X ref var volume = entryCost; // amount = number in args[0] // Filter out all the ref var ref = myInv.filter(function (item) { return item.market_hash_name.match("Refined Metal") }); console.log(ref.length); console.log(volume); // Let the user know we don't have enough ref if (ref.length < volume) { unmuteChannel(); console.log('Not enough Keys'); message.reply(notEnough); console.log('------------------------'); return true; // Give up } // Start a new trade offer // Add what we should do to the current trade console.log('Adding '+volume+' Keys'); offer.addTheirItems(ref.slice(0, volume)) // Send the offer offer.send(function (err, status){ if (err) { console.log(err); } else { console.log('Trade offer #'+ offer.id+ ' sent successfully'); // Register the offer id, save it to JSON file client.tradeLinks ['lastguy'] = { name: message.author.tag, tradelink: _message, lastoffer: offer.id } fs.writeFile ('tradeLinks.json', JSON.stringify(client.tradeLinks, null, 4), err => { if (err) throw err; }) message.reply(readyOffer + offer.id + '>'); // Cancels after 2 minutes //offer.data('cancelTime', 120000); // Starts the function myTimer() every 1 seconds to know the status that is on start var myVar = setInterval(myTimer, 1000); function myTimer() { if (ifvartruefalse === "canceled") { clearInterval(myVar); ifvartruefalse = ""; message.channel.send(cancelOffer); unmuteChannel(); console.log('------------------------'); return; } else if (ifvartruefalse === "false"){ clearInterval(myVar); ifvartruefalse = ""; message.reply(deletingCF); unmuteChannel(); console.log('------------------------'); return; } else if (ifvartruefalse === "invalid"){ clearInterval(myVar); ifvartruefalse = ""; message.reply(invalidItems); unmuteChannel(); console.log('------------------------'); return; } else if (ifvartruefalse === "true"){ clearInterval(myVar); message.channel.send(joined); ifvartruefalse = ""; unmuteChannel(); // What to do after user accept the trade var memberilius = `<@${message.author.id}>`; client.raffle[(idraf - 1).toString()][`slot${slot}`] = memberilius fs.writeFile ('raffle.json', JSON.stringify(client.raffle, null, 4), err => { if (err) throw err; }) //return; } //return; } } }); } }); as you can see there is checking on ifvartruefalse to check the result from etradeofferstate (is its true, then offer state is accepted) var ifvartruefalse = ""; manager.on('sentOfferChanged', function(offer, oldState) { console.log(TradeOfferManager.ETradeOfferState[offer.state]); if (offer.id === client.tradeLinks["lastguy"].lastoffer) { client.tradeLinks["lastguy"] = { name:"", tradelink:"", lastoffer:"" } fs.writeFile ('tradeLinks.json', JSON.stringify(client.tradeLinks, null, 4), err => { if (err) throw err; }) if (TradeOfferManager.ETradeOfferState[offer.state] === "Declined") { if (offer.itemsToGive.length == 0){ ifvartruefalse = "false"; console.log('User/Bot declined'); return; } } else if (TradeOfferManager.ETradeOfferState[offer.state] === "Accepted"){ if (offer.itemsToGive.length == 0){ console.log("User accepted"); ifvartruefalse = "true"; return; } } else if (TradeOfferManager.ETradeOfferState[offer.state] === "InvalidItems") { if (offer.itemsToGive.length == 0){ console.log("Invalid items"); ifvartruefalse = "invalid"; return; } } else if (TradeOfferManager.ETradeOfferState[offer.state] === "Canceled") { if (offer.itemsToGive.length == 0){ ifvartruefalse = "canceled"; console.log('Bot canceled the offer after 2 mins'); } } } }); Could someone please help me ? There is no reason that the bot cancel... Edited December 1, 2020 by EnelGy Quote
apibot Posted December 2, 2020 Report Posted December 2, 2020 check your trademanager constructor? Quote
aethez Posted December 19, 2020 Report Posted December 19, 2020 As far as I know offer.data() only allows you to store data. So like apibot said you would need to use the property cancelTime in the constructor. More info: https://github.com/DoctorMcKay/node-steam-tradeoffer-manager/wiki/TradeOfferManager#canceltime 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.