So I have this function called "sendKeysBuy" that works perfectly fine, but the second function "sendKeysSell", it give me this error " ReferenceError: offer is not defined
at sendKeysSell (C:\Users\Eberh\Desktop\programs\bots\EnvyMarket Trade Bot\BACKUP 3.12.22.15.42\trade_accepter_bot.js:212:3)
at Timeout._onTimeout (C:\Users\Eberh\Desktop\programs\bots\EnvyMarket Trade Bot\BACKUP 3.12.22.15.42\trade_accepter_bot.js:118:6)
at listOnTimeout (node:internal/timers:559:17)
at processTimers (node:internal/timers:502:7) "
function sendKeysBuy(link, amt) {
try {
manager.loadInventory(440, 2, true, (err, inventory) => {
if (err) {
console.log(err);
return;
}
let offer = manager.createOffer(link);
let keys = inventory.filter(item => item.market_name == 'Mann Co. Supply Crate Key');
let keyAmt = keys.slice(0, amt);
offer.addMyItems(keyAmt);
offer.send((err, status) => {
if(err) {
//console.log(err);
} else{
//console.log(status)
}
});
});
} catch (err) {
}
}
function sendKeysSell(link, amt) {
try {
offer.loadPartnerInventory(440, 2, true, (err, inventory) => {
if (err) {
console.log(err);
return;
}
var offer = manager.createOffer(link);
let keys = inventory.filter(item => item.market_name == 'Mann Co. Supply Crate Key');
let keyAmt = keys.slice(0, amt);
offer.addTheirItems(keyAmt);
offer.send((err, status) => {
if(err) {
console.log(err);
} else{
//console.log(status)
}
});
});
} catch (err) {
console.log(err);
}
}