user3773210 user3773210 - 1 year ago 272
Javascript Question

Node js steam trade bot

I'm trying to make a trade bot, but I have a problem with it. When I make an offer to the bot and I want to accept it, the bot doesn't do anything. Decline is working very well, but the accept is not.

https://github.com/seishun/node-steam-trade

Here is my code:

steam.on('tradeOffers', function(number) {
if (number > 0) {
offers.getOffers({
get_received_offers: 1,
active_only: 1,
time_historical_cutoff: Math.round(Date.now() / 1000)
}, function(error, body) {
if(body.response.trade_offers_received){
body.response.trade_offers_received.forEach(function(offer) {
if (offer.trade_offer_state == 2) {

console.log(offer);
if(offer.items_to_receive){
if(!offer.items_to_give){
offers.acceptOffer(offer.tradeofferid);
}else {
offers.declineOffer(offer.tradeofferid);
}
}else {
offers.declineOffer(offer.tradeofferid);
}
}
});
}
});
}
});

Answer Source

if(offer.items_to_receive) Is the problem, offer.items_to_receive will immediately return false since you are not asking for a specific item.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download