// Get all active offers
manager.getOffers(TradeOfferManager.EOfferFilter.ActiveOnly, (err, sent, received) => {
// Loop through recieved trade offers and execute the processOffer function on each.
if (received) {
for (var i = 0; i < received.length; i++) {
processOffer(received[i]);
}
}
});
You could put the above in a setInterval.
The processOffer function is the same thing that you do when you get the newOffer event.
So if you have a large function like:
manager.on('newOffer', offer => {
// code
});
You can change it to:
manager.on('newOffer', offer => processOffer(offer));
function processOffer(offer) {
// code
}
And so then you can process an offer from elsewhere.