DoctorMcKay/node-steam-tradeoffer-manager

TypeError: Cannot read property 'itemsToGive' of undefined

2cab opened this issue · 0 comments

2cab commented

i having some errors with my code and some of the stuff in the module. Any ideas?

here is my code

`function process(offer) {
client.setPersona(SteamUser.EPersonaState.Busy);
var our_items = offer.itemsToGive;
var their_items = offer.itemsToReceive;

if(offer.isGlitched() || offer.state == 11)
    decline(offer);
else if(offer.partner.getSteamID64() == config.owner.ID64) 
    accept(offer);
else
    for (var i in our_items)
        var item = our_items[i];
        var name = item.market_hash_name
        if(isTF2()) {
            if(Prices[name]) 
                ours += Math.ceil(Prices[name].sell * 9);
        else 
            ours += Math.pow(2, 50)
        }
            
    for(var i in their_items) 
        var item = their_items[i];
        var name = item.market_hash_name;
        if(isTF2()) {
            if(Prices[name])
                theirs += Math.ceil(Prices[name].buy * 9);
        }

print(`${log('trade')} Their value: ${Math.floor(theirs / 9 * 100) / 100} ref`); 
print(`${log('trade')} They want: ${Math.floor(ours / 9 * 100) / 100} ref`); 

if (ours <= theirs) {
    offer.getUserDetails((err, them) => {
        if (err) {
            throw err;
        }
        else if(offer.itemsToGive.length == 0 && offer.itemsToReceive.length > 0) {
            offer.accept((err) => {
                if(err) print(`${log('trade')} ${err}`);
                print(`${log('trade')}   Trying to accept incoming donation.`);
                client.chatMessage(offer.partner.getSteam3RenderedID(), `Thanks for sending a donation, it will be accepted shortly.`)
            })
        }
        else if (them.escrowDays > 0) {
            escrow(offer);
        } else {
            accept(offer); 
        }
    });
} else {
    decline(offer);
}

}`