Jump to content


Photo
Question

Adding a small delay

node.js node-steam-tradeoffer-manager

Best Answer Dr. McKay , 17 January 2019 - 06:52 PM

I really don't mind necroing on this forum.

 

You definitely need to put the confirmation acceptance inside the callback to accept, but within that callback it's not a bad idea to add a short delay. Use setTimeout for this.

Go to the full post


  • Please log in to reply
3 replies to this topic

#1 roughnecks

roughnecks

    Advanced Member

  • Member
  • PipPipPip
  • 40 posts

Posted 16 January 2019 - 04:38 PM

community.acceptConfirmationForObject(identitySecret, offer.id, function(err) {
	if(err){
		console.log(chalk.red("Confirmation Failed for  " + offer.id + ": " + err));
	} else {
		console.log(chalk.green("Offer " + offer.id + ": Confirmed!"));
	}
});

How can I delay this ^ for a couple seconds, avoiding it being fired earlier than offer.accept (which is right before)?

 

I know this is more a coding issue rather than module's issue but I'm beginning to code in js and this async stuff hurts :) Thanks



#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,944 posts

Posted 17 January 2019 - 05:12 AM

Put it inside of the callback to accept.



#3 roughnecks

roughnecks

    Advanced Member

  • Member
  • PipPipPip
  • 40 posts

Posted 17 January 2019 - 06:27 AM

This is my code:

	if (offer.partner.getSteamID64() === '76561198061492959') {
		offer.accept((err, status) => {
			if (err) {
				console.log(err);
			} else {
				console.log(chalk.green(`Accepted offer ${offer.id} from owner. Status: ${status}.`));
				community.acceptConfirmationForObject(identitySecret, offer.id, function(err) {
					if(err){
						console.log(chalk.red("Confirmation Failed for  " + offer.id + ": " + err));
					} else {
						console.log(chalk.green("Offer " + offer.id + ": Confirmed!"));
					}
				});
			}
		});

It's working fine (at least when I tried) but I read on another thread where you suggested to add a delay just to be sure the confirmation would fire after accepting the offer - and I didn't want to necro that post.



#4 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,944 posts

Posted 17 January 2019 - 06:52 PM   Best Answer

I really don't mind necroing on this forum.

 

You definitely need to put the confirmation acceptance inside the callback to accept, but within that callback it's not a bad idea to add a short delay. Use setTimeout for this.


  • roughnecks likes this





Also tagged with one or more of these keywords: Question, node.js, node-steam-tradeoffer-manager

6 user(s) are reading this topic

0 members, 6 guests, 0 anonymous users