Jump to content
McKay Development
TextDynasty

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

Recommended Posts

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';
        }
    });
}

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...