Jump to content
McKay Development

Trying to use SteamUser Trade function


Adaaam95

Recommended Posts

Hello all,

 

Not sure if I'm posting this in the right place or if anyone can help me but I'm trying to make a trading bot for the first time and I'm having trouble trying to send a trade request to my friend.

 

Here's the code:

 

var SteamUser = require('steam-user'); // The heart of the bot.  We'll write the soul ourselves.
var SteamTrade = require('steam-trade');


var username = 'test';
var password = 'test';


// We have to use application IDs in our requests--this is just a helper
var appid = {
    TF2:   440,
    DOTA2: 570,
    CSGO:  730,
    Steam: 753
};
// We also have to know context IDs which are a bit tricker since they're undocumented.
// For Steam, ID 1 is gifts and 6 is trading cards/emoticons/backgrounds
// For all current Valve games the context ID is 2.
var contextid = {
    TF2:   2,
    DOTA2: 2,
    CSGO:  2,
    Steam: 6
}


// Initialize the Steam client and our trading library
var client = new SteamUser();
//steam client
var trade = new SteamTrade();
//steam trade


// Sign into Steam
client.logOn({
    accountName: username,
    password: password
});


client.on('loggedOn', function (details) {
    logger.info("Logged into Steam as " + client.steamID.getSteam3RenderedID());
});


client.on('error', function (e) {
    logger.error(e);
    process.exit(1);
});


client.on('webSession', function(sessionid) {
    trade.sessionID = sessionid;
    client.webLogOn(function(cookie) {
        cookie.forEach(function(part) {
            trade.setCookie(part.trim());
        });
        logger.info('Logged into web');
        // No longer appear offline
        client.setPersonaState(steam.EPersonaState.LookingToTrade); 
    });
});


client.trade('STEAM_0:1:55683311');

I'm using some outdated tutorials from google ( I'm on the right track with it but I can't work out what I'm doing wrong.

 

I keep running the script but my friend isn't getting a trade request so I don't know what I'm missing from it.

 

Any help would be appreciated.

 

Thanks,

Adam

 

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