Jump to content
McKay Development

Im having some trouble when trying to make my steam bot because i have the node module downloaded but it keeps giving me this error


Recommended Posts

Posted
C:\Users\serbe\Downloads\bot\bot.js:79
    var our_items = offer.itemsToGive;
                          ^

TypeError: Cannot read property 'itemsToGive' of undefined
    at process (C:\Users\serbe\Downloads\bot\bot.js:79:27)
    at TradeOfferManager.<anonymous> (C:\Users\serbe\Downloads\bot\bot.js:134:3)
    at TradeOfferManager.emit (events.js:311:20)
    at C:\Users\serbe\Downloads\bot\node_modules\steam-tradeoffer-manager\lib\polling.js:239:10
    at Array.forEach (<anonymous>)
    at C:\Users\serbe\Downloads\bot\node_modules\steam-tradeoffer-manager\lib\polling.js:223:12
    at C:\Users\serbe\Downloads\bot\node_modules\steam-tradeoffer-manager\lib\index.js:509:4
    at C:\Users\serbe\Downloads\bot\node_modules\steam-tradeoffer-manager\lib\assets.js:171:4
    at C:\Users\serbe\Downloads\bot\node_modules\async\dist\async.js:1140:9
    at C:\Users\serbe\Downloads\bot\node_modules\async\dist\async.js:473:16

C:\Users\serbe\Downloads\bot>

 

Posted

i did that and now im getting this in console. 

C:\Users\serbe\Downloads\bot\bot.js:70
    if (offer.isGlitched() || offer.state === 11) {
              ^

TypeError: Cannot read property 'isGlitched' of undefined
    at processOffer (C:\Users\serbe\Downloads\bot\bot.js:70:15)
    at TradeOfferManager.<anonymous> (C:\Users\serbe\Downloads\bot\bot.js:108:3)
    at TradeOfferManager.emit (events.js:311:20)
    at C:\Users\serbe\Downloads\bot\node_modules\steam-tradeoffer-manager\lib\polling.js:239:10
    at Array.forEach (<anonymous>)
    at C:\Users\serbe\Downloads\bot\node_modules\steam-tradeoffer-manager\lib\polling.js:223:12
    at C:\Users\serbe\Downloads\bot\node_modules\steam-tradeoffer-manager\lib\index.js:509:4
    at C:\Users\serbe\Downloads\bot\node_modules\steam-tradeoffer-manager\lib\assets.js:171:4
    at C:\Users\serbe\Downloads\bot\node_modules\async\dist\async.js:1140:9
    at C:\Users\serbe\Downloads\bot\node_modules\async\dist\async.js:473:16

 

Posted
const TradeOfferManager = require('steam-tradeoffer-manager');
const SteamCommunity = require('steamcommunity');
const SteamUser = require('steam-user');
const SteamTotp = require('steam-totp');

const Prices = require('./prices.json');
const config = require('./config.json');

const client = new SteamUser();
const community = new SteamCommunity();
const manager = new TradeOfferManager({
	steam: client,
	community: community,
	language: 'en'
});


const logOnOptions = {
	accountName: config.username,
	password: config.password,
	twoFactorCode:SteamTotp.generateAuthCode(config.sharedSecret)
};

client.logOn(logOnOptions);

client.on('loggedOn', () => {
	console.log('Succesfully logged on.');
	client.setPersona(SteamUser.EPersonaState.Online, 'BOT');
	client.gamesPlayed(440);
});

client.on('friendRelationship', (steamid, relationship) => {
  if (relationship === 2) {
    client.addFriend(steamid);
    client.chatMessage(steamid, 'Hello there! Thanks for adding me!');
    console.log("Added a friend")
  }
});

client.on('webSession', (sessionid, cookies) => {
    manager.setCookies(cookies);
    community.setCookies(cookies);
    community.startConfirmationChecker(20000, config.identitySecret);
});


function acceptOffer(offer) {
    offer.accept((err) => {
        community.checkConfirmations();
        console.log("We Accepted an offer");
        if (err) console.log("There was an error accepting the offer.");
    });
}
 
function declineOffer(offer) {
    offer.decline((err) => {
        console.log("We Declined an offer");
        if (err) console.log("There was an error declining the offer.");
    });
}





function processOffer(offer) {
    if (offer.isGlitched() || offer.state === 11) {
        console.log("Offer Declined!");
        declineOffer(offer);
    } else if (offer.partner.getSteamID64() === config.ownerID) {
        acceptOffer(offer);
    } else {
        var ourItems = offer.itemsToGive;
        var theirItems = offer.itemsToReceive;
        var ourValue = 0;
        var theirValue = 0;
        for (var i in ourItems) {
            var item = ourItems[i].market_name;
            if(Prices[item]) {
                ourValue += Prices[item].sell;
            } else {
                console.log("Invalid value.");
                ourValue += 99999;
            }
        }
        for(var i in theirItems) {
            var item= theirItems[i].market_name;
            if(Prices[item]) {
                theirValue += Prices[item].buy;
            } else {
            }
        }
    }
 
    if (ourValue <= theirValue) {
        acceptOffer(offer);
    } else {
        declineOffer(offer);
    }
}



client.setOption("promptSteamGuardCode", false);

manager.on('newOffer', offer => {
  processOffer();
});

 

Posted (edited)

@2can

your newOffer event should be

processOffer(offer)

 Its better off you coding it yourself since you can learn your mistake and improve. Not by copying blindly from others and not knowing what is it doing

Edited by xLeeJYx
quote is too long

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