Jump to content


Photo

Is there a way to accept a certain trade offer through message with its offerid?

node.js node-steam-tradeoffer-manager

Best Answer Dr. McKay , 23 January 2019 - 08:04 PM

You'll need to retrieve the offer first.

Go to the full post


  • Please log in to reply
4 replies to this topic

#1 TextDynasty

TextDynasty

    Advanced Member

  • Member
  • PipPipPip
  • 139 posts

Posted 23 January 2019 - 08:00 PM

Hi, so I wrote a few codes to my bot to make it send me a message with offer id included once there's a need for the background check. But I don't know how or is there a way to make it accept the trade offer through providing the trade offer id to the bot.

const parseAdminMessage = (message) =>{
 if (message.substring(0,8) == '!accept '){
    var offerid = message.substring(8);
    console.log(offerid); //It can show the correct offerid here but i dont know how to make it accept the trade by the offerid
}

//This is what I used to accept normal trade offer with the offer status

const acceptTradeOffer = (offer) => {
    offer.accept(false, function(error, status) {
        if (error) {
            logger.error(`| OFFER RECEIVED |: ID#${offer.id} has failed trying to accept it. Reason: Offer is no longer valid.`);
            return 'Badass';
        } else if (status === 'pending') {
            logger.info(`| OFFER NEEDS CONFIRM | : ID#${offer.id} is accepted but needs confirmation`);
            var confCount = 0;
            function confirm(idSecret, idOffer) {
                community.acceptConfirmationForObject(idSecret, idOffer, function(error) {
                    confCount++
                    if (error) {
                        if (confCount < 4) {
                            confirm(idSecret, idOffer);
                        } else {
                          logger.error(error);
                            logger.fail(`| OFFER RECEIVED | : ID#${offer.id} has failed trying to confirm it. Reason: Offer is no longer valid.`);
                            return 'done';
                        }
                    } else {
                        return 'done';
                    }
                });
            }
            confirm(config.identity_secret, offer.id);
        } else {
            return 'done';
        }
    });
}


#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,187 posts

Posted 23 January 2019 - 08:04 PM   Best Answer

You'll need to retrieve the offer first.



#3 TextDynasty

TextDynasty

    Advanced Member

  • Member
  • PipPipPip
  • 139 posts

Posted 23 January 2019 - 08:53 PM

You'll need to retrieve the offer first.

 if (message.substring(0,8) == '!accept '){
    var offerid = message.substring(8);
    manager.getOffer(offerid, function(offer) {
        offer.accept(false, function(error, status) {
            if (error) {
                logger.error(`| OFFER RECEIVED |: ID#${offer.id} has failed trying to accept it. Reason: Offer is no longer valid.`);
                return;
            } else if (status === 'pending') {
                logger.info(`| OFFER NEEDS CONFIRM | : ID#${offer.id} is accepted but needs confirmation`);
                community.acceptConfirmationForObject(config.identity_secret, offer.id);
            }
        })
    })
  }

Is this what you mean by getOffer?

 

It has this error

        offer.accept(false, function(error, status) {
              ^

TypeError: Cannot read property 'accept' of null
    at C:\Users\lokin\OneDrive\桌面\item933\app.js:188:15
    at Helpers.checkNeededDescriptions (C:\Users\lokin\OneDrive\桌面\item933\node_modules\steam-tradeoffer-manager\lib\index.js:437:4)
    at Object.exports.checkNeededDescriptions (C:\Users\lokin\OneDrive\桌面\item933\node_modules\steam-tradeoffer-manager\lib\helpers.js:90:3)
    at _apiCall (C:\Users\lokin\OneDrive\桌面\item933\node_modules\steam-tradeoffer-manager\lib\index.js:431:11)
    at SteamCommunity._community.httpRequest (C:\Users\lokin\OneDrive\桌面\item933\node_modules\steam-tradeoffer-manager\lib\webapi.js:61:3)
    at Request._callback (C:\Users\lokin\OneDrive\桌面\item933\node_modules\steamcommunity\components\http.js:67:15)
    at Request.self.callback (C:\Users\lokin\OneDrive\桌面\item933\node_modules\request\request.js:185:22)
    at Request.emit (events.js:182:13)
    at Request.<anonymous> (C:\Users\lokin\OneDrive\桌面\item933\node_modules\request\request.js:1161:10)
    at Request.emit (events.js:182:13)
Press any key to continue . . .

Edited by TextDynasty, 23 January 2019 - 09:13 PM.


#4 TextDynasty

TextDynasty

    Advanced Member

  • Member
  • PipPipPip
  • 139 posts

Posted 23 January 2019 - 10:30 PM

Solved.  Thanks McKay



#5 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,187 posts

Posted 24 January 2019 - 05:20 AM

Please post your solution for others in the future.

 

In this case, the problem was that the first argument to the callback should be err, not offer.







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

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users