Jump to content
McKay Development

Sending trade offer error


Recommended Posts

I want to send trade offer where i add only somebody's item.

function sendSomeItem() {

    const partner = '76561198989375284';
    const appid = 730;
    const contextid = 2;
    const offer = manager.createOffer(partner);

    manager.loadInventory(appid, contextid, true, (err, myInv) => {

        if (err) {
            console.log(err);
        } else {
            manager.loadUserInventory(partner, appid, contextid, true, (err, theirInv) => {
                if (err) {
                    console.log(err);
                } else {
                    offer.addTheirItem({
                        'assetid': 18697938160,
                        'appid': appid,
                        'contextid': contextid
                    });
                    offer.setMessage('Test offer');
                    offer.send((err, status) => {
                        if (err) {
                            console.log(err);
                        } else {
                            console.log(`Sent offer. Status: ${status}.`);
                        }
                    });
                }
            });
        }
    });
}

I use this simple code to test my code. It logging me, and after delay, trying to send a trade offer. 

client.logOn(logInOptions);
client.on('loggedOn', () => {
	console.log('logged on');
	setTimeout(sendSomeItem, 5000);
});

But i get this error:

logged on
Error: Malformed response
    at SteamCommunity.<anonymous> (C:\Users\jmazu\Desktop\node-steam-bot\node_modules\steamcommunity\components\users.js:353:15)
    at Request._callback (C:\Users\jmazu\Desktop\node-steam-bot\node_modules\steamcommunity\components\http.js:67:15)
    at Request.self.callback (C:\Users\jmazu\Desktop\node-steam-bot\node_modules\request\request.js:185:22)
    at Request.emit (events.js:315:20)
    at Request.<anonymous> (C:\Users\jmazu\Desktop\node-steam-bot\node_modules\request\request.js:1154:10)
    at Request.emit (events.js:315:20)
    at Gunzip.<anonymous> (C:\Users\jmazu\Desktop\node-steam-bot\node_modules\request\request.js:1076:12)
    at Object.onceWrapper (events.js:421:28)
    at Gunzip.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1221:12)

I don't know what is wrong. Logging works fine.

Edited by Shiny
Code change
Link to comment
Share on other sites

You don't need to load someone's inventory if you know the asset ID you plan on putting in the trade offer already.

Can you determine which line you're receiving the error on? That error could be coming from either manager.loadInventory or manager.loadUserInventory.

Link to comment
Share on other sites

I deleted useless code

function sendSomeItem() {
	console.log('function started')
    const partner = '76561198989375284';
    const appid = 730;
    const contextid = 2;
    const offer = manager.createOffer(partner);

    offer.addTheirItem({
        'assetid': 18697938160,
        'appid': appid,
        'contextid': contextid
    });
    offer.setMessage('Test offer');
    offer.send((err, status) => {
        if (err) {
            console.log(err);
        } else {
            console.log(`Sent offer. Status: ${status}.`);
        }
    });
}

Now i get function started and error that i must have steam guard for at least 15 days. So i think this is working ;) Thank you so much for that fast answers <3 

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...