Jump to content
McKay Development

Send an offer with an item from a received offer?


Recommended Posts

I'm trying to send an offer to an ID with an item the bot got from another offer whenever it accepts, the code looks something like this (this is the accept function I use whenever I want to accept an offer):

 

function acceptOffer(offer) {
    var newOffer = manager.createOffer(SOMEID);
    newOffer.addMyItem(offer.itemsToReceive[0]);
    offer.accept((err) => {
        community.checkConfirmations();
        if (err) console.log("There was an error accepting the offer.");
    });
    newOffer.send(function(err, status) {console.log('error: '+err+'status: '+status)});
    console.log(newOffer.state);
};
 
When I run this, the state logs as 1, which means invalid, so Im not entirely sure on how to do this. Any ideas?
Edited by HeilShuckle
Link to comment
Share on other sites

It should look like this:

function acceptOffer(offer) {
    offer.accept((err) => {
        community.checkConfirmations();
        if (err) console.log("There was an error accepting the offer.");
        manager.getOffer(offer.id, function(er, of) {
            if(er) throw er;

            var itemsReceived = of.itemsToReceive;
            var newOffer = manager.createOffer(SOMEID);
            newOffer.addMyItem(itemsReceived[0]);
            newOffer.send(function(err, status) {console.log('error: '+err+' status: '+status)});
            console.log(newOffer.state);
        });
    });
};

Hope it works! :P

Edited by Andrei Elvis
Link to comment
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...