Jump to content


Photo
Question

Error: This trade offer is no longer valid.

node.js node-steam-tradeoffer-manager

Best Answer Dr. McKay , 14 January 2019 - 09:36 PM

You're firing off getUserDetails and accept at the same time. The accept request is probably getting processed by Steam before the details one, and thus Steam no longer believes the offer is active when the details request gets processed.

Go to the full post


  • Please log in to reply
7 replies to this topic

#1 roughnecks

roughnecks

    Advanced Member

  • Member
  • PipPipPip
  • 34 posts

Posted 28 December 2018 - 08:24 AM

Hello

 

My bot is not running. I send an offer to it and then start it. Trade offer gets accepted but I get the error message "This trade offer is no longer valid."

 

It's happening when retrieving UserDetails:

		if (offer.itemsToGive.length === 0) {

			offer.getUserDetails((err, me, them) => {
				if (typeof (them) !== 'undefined') {
					donator = them.personaName;
					console.log(`donator is: ${donator}`);
				} else { console.log(err); }
			});

because I'm not getting donator's name.

 

 

This is my console.log:

Error: This trade offer is no longer valid.
    at SteamCommunity._checkTradeError (D:\Portable\Birba\node_modules\steamcommunity\components\http.js:144:13)
    at Request._callback (D:\Portable\Birba\node_modules\steamcommunity\components\http.js:52:80)
    at Request.self.callback (D:\Portable\Birba\node_modules\request\request.js:185:22)
    at Request.emit (events.js:182:13)
    at Request.<anonymous> (D:\Portable\Birba\node_modules\request\request.js:1161:10)
    at Request.emit (events.js:182:13)
    at Gunzip.<anonymous> (D:\Portable\Birba\node_modules\request\request.js:1083:12)
    at Object.onceWrapper (events.js:273:13)
    at Gunzip.emit (events.js:187:15)
    at endReadableNT (_stream_readable.js:1094:12)
Donation accepted. Status: accepted.
 

Problem is, I'm posting a comment on bot's profile upon successful incoming donation and if there are offers BEFORE I run the bot, comments are not posted, since there's a check on "donator" and it doesn't return.

 

BUT:

 

If I keep the bot running and then send one more offer, it gets accepted and all is working fine without errors.

 

donator is: roughnecks

 

Donation accepted. Status: accepted.

 

Comment Posted



#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,879 posts

Posted 29 December 2018 - 01:44 AM

You cannot call getUserDetails on a trade offer that is not active.



#3 roughnecks

roughnecks

    Advanced Member

  • Member
  • PipPipPip
  • 34 posts

Posted 29 December 2018 - 04:58 AM

I read that in the doc but what's your definition of active? Maybe you mean that it's not a "new" trade offer but when a trade is pending to me is still "active" because I can accept it until it's canceled.

 

So there's no other way to get sender's name for all the trades if I can't keep my bot always running?



#4 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,879 posts

Posted 30 December 2018 - 01:00 AM

Active means its state on Steam is Active. Anything that you can accept but haven't yet is active and you should be able to use getUserDetails on it.

 

To get user details for trade offers that are no longer active, you'll need to use the WebAPI.



#5 roughnecks

roughnecks

    Advanced Member

  • Member
  • PipPipPip
  • 34 posts

Posted 13 January 2019 - 06:21 AM

Still I don't understand why it's happening only for the first incoming offer, while all the following ones are working fine.



#6 roughnecks

roughnecks

    Advanced Member

  • Member
  • PipPipPip
  • 34 posts

Posted 13 January 2019 - 10:40 AM

manager.on('newOffer', offer => {

	if (offer.partner.getSteamID64() === '76561198061492959') {
		offer.accept((err, status) => {
			if (err) {
				console.log(err);
			} else {
				console.log(`Accepted offer from owner. Status: ${status}.`);
			}
		});
	} else {

		if (offer.itemsToGive.length === 0) {

			offer.getUserDetails((err, me, them) => {
				if (typeof (them) !== 'undefined') {
					donator = them.personaName;
					//console.log(`donator is: ${donator}`);
				} else { console.log('getuserdetails' + err); }
			});

			offer.accept((err, status) => {

				offer.getReceivedItems((err, items) => {
					if (typeof (items) !== 'undefined') {
						donationnum = items.length;
						//console.log(`donationnum is: ${donationnum}`);
					} else { console.log('getreceiveditems' + err); }
				});

				if (err) {
					console.log(err);
				} else {
					console.log(`Donation accepted. Status: ${status}.`);
					success = 1;
				}
			});

			setTimeout(postComment, 3000);

		} else {
			offer.decline(err => {
				if (err) {
					console.log(err);
				} else {
					console.log('Offer declined (wanted our items).');
				}
			});
		}
	}
});


#7 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,879 posts

Posted 14 January 2019 - 09:36 PM   Best Answer

You're firing off getUserDetails and accept at the same time. The accept request is probably getting processed by Steam before the details one, and thus Steam no longer believes the offer is active when the details request gets processed.



#8 roughnecks

roughnecks

    Advanced Member

  • Member
  • PipPipPip
  • 34 posts

Posted 15 January 2019 - 05:48 AM

I see, thanks.







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

3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users