Jump to content


Photo
Question

My manage New offer code is not working

node.js node-steam-tradeoffer-manager steam bot error ownerID newOffer SteamID64

  • Please log in to reply
1 reply to this topic

#1 UnmetPlayer

UnmetPlayer

    Newbie

  • Member
  • Pip
  • 1 posts

Posted 11 June 2019 - 04:52 PM

I get a number of different errors when running the bot and they are always to do with the offers. This is what I have so far with the new offer for a stranger and the owner offer stuff. Just to let anyone know this bot sells TF2 Scrap for Steam Emoticons. The Code:

manager.on('newOffer', (offer) => {
    let counter = 0
    if (offer.itemsToGive.length == offer.itemsToReceive.length) {
    	for (let i = 0; i < offer.itemsToGive.length; i++) {
    		if (offer.itemsToReceive[i].type.includes("Emoticon") && offer.itemsToGive[i].name == "Scrap Metal") {
    			counter++
    		}
    	}
    	if (counter == offer.itemsToGive.length) {
    		offer.accept(function(err, status) {
    			if (err) {
    				console.log("Unable to accept offer: " + err.message);
    			} else {
    				console.log("Offer accepted: " + status);
    				if (status == "pending") {
    					community.acceptConfirmationForObject(config.identity, offer.id, function(err) {
    						if (err) {
    							console.log("Can't confirm trade offer: " + err.message);
    						} else {
    							console.log("Trade offer " + offer.id + " confirmed");
    						}
    					})
    				}
    			}
    		})
    	}
    } else if (offer.itemsToGive.length == 0){
	    offer.accept((err, status) => {
	      if (err) {
	        console.log(err);
	      } else {
	        console.log(`Donation accepted. Status: ${status}.`);
	      }
	    });
    } else {
	    offer.decline(err => {
	      if (err) {
	        console.log(err);
	      } else {
	        console.log('Donation declined (wanted our items).');
	      }
	    });
    }
});
//owner send trade, bot instantly accepts
manager.on('newOffer', (offer) => {
	if (offer.partner.getSteamID64() === config.ownerID) {
		acceptOffer(offer);
		console.log("Successfully accepted")
	} else {
		delcineOffer(offer);
	}
});

Some examples of errors I get, "Cannot read property 'partner' of undefined" that error is from the owner code. Then when removing that code the bot works, but it means I cannot send trades as the owner with out logging onto the bot's account and accepting it manually. 

 

I hope someone can help me.

Thanks

Unmet



#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,166 posts

Posted 11 June 2019 - 08:27 PM

I suspect that you're having problems because you have two newOffer handlers. They will both fire, so you'll be trying to decline all offers that aren't sent by the owner, even if they should be accepted by your trading logic.







Also tagged with one or more of these keywords: Question, node.js, node-steam-tradeoffer-manager, steam bot, error, ownerID, newOffer, SteamID64

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users