MrInka Posted October 15, 2016 Report Posted October 15, 2016 Hey, I am still not too good with Node or JS, but working on it! I have a working NodeJS bot to accept item donations. Sometimes, offers are glitched. The bots console log tell me, that it accepted them, which of course doesn't work. If I restart the bot, it finds the offer and accepts it (if it's not glitched anymore). I managed to let the bot find out if an offer is glitched. if(offer.isGlitched() == true) { console.log("Offer is glitched!"); } else { console.log("Offer is not glitched!"); }Now ... since I don't fully understand how the bot gets the new offers, I don't know how to manually refresh them. Lets say, I would use the code above right after a new offers is received and "isGlitched()" equals "true", what would I need to have a few seconds delay and then just refresh all offers until the offer is not glitched anymore? if(offer.isGlitched() == true) { console.log("Offer is glitched!"); setTimeout(function(){ //Reload offers! }, 15000); } else { console.log("Offer is not glitched!"); //Some conditions offer.accept();" } What would I need as "Reload offers!"? This might be some easy-to-solve question, but I tried and didn't succeed. Any help is greatly appreciated! Quote
MrInka Posted October 17, 2016 Author Report Posted October 17, 2016 (edited) Hey and thank you,I found an answer made by you on here. offer.update(function(err) { if (err) { console.log(err); } else { // now the offer is fresh from the WebAPI } });I was just wondering, If my bot finds a new offer, sees that it's glitched and runs the code above instead of accepting / checking trade conditions, will the same offer just pop up again? Will he then find it automatically Or will I need to tell my bot to "forget" the offer he just found after / before I updated? Edited October 17, 2016 by MrInka Quote
Dr. McKay Posted October 17, 2016 Report Posted October 17, 2016 In the callback, provided it was successful, the offer's data will be updated and you can just run your logic there. But no, it won't arrive in newOffer again once it's emitted once. 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.