Jump to content
McKay Development

Getting ReferenceError: manager is not defined


Recommended Posts

Im getting this error "ReferenceError: manager is not defined" when I try to start a trade. 

 

This is where its saying the error is, not sure if I used this properly.

Also below is my code so far some of its hard coded for testing. Im using socket.io to send trades from client to server side.

var offer = manager.createOffer('https://steamcommunity.com/tradeoffer/new/?partner=113526536&token=xxxxxxxx');
 
 
/*
Socket Setup Start
-creating vars
-creating server
*/
 
var http  = require("http");
var fs    = require("fs");
var io    = require('socket.io').listen(8000);
 
function genericRspnd(request, response){
    response.writeHead(200, {'Content-Type':'text/html'});
    response.end(fs.readFileSync('inv.php')); //place user on socket
}
 
/*
Socket Setup End
*/
 
 
 
//actual steam-sided bot
    var SteamUser = require("steam-user");
    var SteamTotp = require("steam-totp");
    var TradeOfferManager = require("steam-tradeoffer-manager");
    var SteamCommunity = require("steamcommunity"); //general npms
    var manager = new TradeOfferManager({
            "language": "en",
            "domain": "http://94.23.58.154/",
            "pollInterval": "10000"
    });
 
    var community = new SteamCommunity();
    var client = new SteamUser();
 
    client.logOn({
        accountName: CONFIG.USERNAME,
        password: CONFIG.PASSWORD,
        twoFactorCode: SteamTotp.getAuthCode(CONFIG.SHAREDSECRET)
    });
 
    client.on("loggedOn", (details, parental) => {
        client.getPersonas([client.steamID], (personas) => {
            console.log("## Logged in as #" + client.steamID + " (" + personas[client.steamID]["player_name"] + ")");
        });
        client.setPersona(1);
    });
 
    client.on("webSession", (sessionID, cookies) => {
        manager.setCookies(cookies, (err) => {
            if (err) {
                console.log("## An error occured while setting cookies.");
            } else {
                console.log("## Websession created and cookies set.");
            }
        });
        community.setCookies(cookies);
        community.startConfirmationChecker(10000, CONFIG.IDENTITYSECRET);
    }); //create cookies
 
    community.on("sessionExpired", (err) => {
        community.stopConfirmationChecker();
        console.log("## Session Expired, relogging.");
        client.webLogOn();
    });
 
    });
   
 
    /*
    How this bot will work :
    1) recieves all the information via sockets
    2) creates offer with tradeurl
    3) adds the persons' items via the assetid
    4) adds our items via the assetid
    5) sets trade offer message
    6) sends trade offer, if everything goes well it will log the trade offer id and the status
    */
 
    io.sockets.on('connection', function (client){
        console.log("A user connected to the website");
       
        client.on('tradeOffer', function (steamid, assetid) {
 
        console.log("Recieved a trade request from : " + steamid + "." );
 
        var offer = manager.createOffer('https://steamcommunity.com/tradeoffer/new/?partner=113526536&token=qx0l3qae');
   
        offer.addTheirItem({"appid": 730, "contextid": 2, "assetid": 8251852579});
        //offer.addMyItem({"appid:730", "contextid": 2, "assetid": myId});
        offer.setMessage("Thank you for trading with us!");
   
        offer.send(function (err, status){
            if (err) {
                console.log(err);
                return;
            } else {
               console.log("Trade offer #" + offer.id + " "+ status );
            }
       
 
    });
 
});
Edited by Alex Lucas
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...