I get a number of different errors when running the bot and they are always to do with the offers. This is what I have so far with the new offer for a stranger and the owner offer stuff. Just to let anyone know this bot sells TF2 Scrap for Steam Emoticons. The Code:
manager.on('newOffer', (offer) => {
let counter = 0
if (offer.itemsToGive.length == offer.itemsToReceive.length) {
for (let i = 0; i < offer.itemsToGive.length; i++) {
if (offer.itemsToReceive[i].type.includes("Emoticon") && offer.itemsToGive[i].name == "Scrap Metal") {
counter++
}
}
if (counter == offer.itemsToGive.length) {
offer.accept(function(err, status) {
if (err) {
console.log("Unable to accept offer: " + err.message);
} else {
console.log("Offer accepted: " + status);
if (status == "pending") {
community.acceptConfirmationForObject(config.identity, offer.id, function(err) {
if (err) {
console.log("Can't confirm trade offer: " + err.message);
} else {
console.log("Trade offer " + offer.id + " confirmed");
}
})
}
}
})
}
} else if (offer.itemsToGive.length == 0){
offer.accept((err, status) => {
if (err) {
console.log(err);
} else {
console.log(`Donation accepted. Status: ${status}.`);
}
});
} else {
offer.decline(err => {
if (err) {
console.log(err);
} else {
console.log('Donation declined (wanted our items).');
}
});
}
});
//owner send trade, bot instantly accepts
manager.on('newOffer', (offer) => {
if (offer.partner.getSteamID64() === config.ownerID) {
acceptOffer(offer);
console.log("Successfully accepted")
} else {
delcineOffer(offer);
}
});
Some examples of errors I get, "Cannot read property 'partner' of undefined" that error is from the owner code. Then when removing that code the bot works, but it means I cannot send trades as the owner with out logging onto the bot's account and accepting it manually. I hope someone can help me. Thanks Unmet