Hello I guess i can`t manage to setup sentOfferChanged event. This is my code:
const SteamUser = require('steam-user');
const TradeOfferManager = require('steam-tradeoffer-manager');
const fs = require('fs')
// steam 2fa. generate steam guard code for login.
const SteamTotp = require('steam-totp');
const bot = new SteamUser();
const manager = new TradeOfferManager({
steam: bot,
language: 'en'
});
if (fs.existsSync('polldata.json')) {
manager.pollData = JSON.parse(fs.readFileSync('polldata.json').toString('utf8'));
}
bot.logOn({
accountName: 'user',
password: 'password',
twoFactorCode: SteamTotp.generateAuthCode('secret')
});
bot.on('webSession', (sessionid, cookies) => {
manager.setCookies(cookies);
sendRandomItem();
});
function sendRandomItem() {
console.log('Sending the offer')
const partner = 'trade_url';
const offer = manager.createOffer(partner);
offer.addTheirItem({
assetid: "id",
appid: 730,
contextid: 2
});
offer.setMessage(
`HIIII`
);
offer.send((err, status) => {
if (err) {
console.log({err});
} else {
console.log(`Sent offer. Status: ${status}.`);
}
});
};
manager.on('sentOfferChanged', function (offer, oldState) {
console.log(`Offer #${offer.id} changed: ${TradeOfferManager.ETradeOfferState[oldState]} -> ${TradeOfferManager.ETradeOfferState[offer.state]}`);
});
manager.on('pollFailure', function (err) {
console.log({err})
})
manager.on('pollData', function (pollData) {
fs.writeFileSync('polldata.json', JSON.stringify(pollData));
});
This is polldata.json
{"sent":{"3358172656":2}}
Console log
$ node ./modules/bot
Sending the offer
Sent offer. Status: sent. But when i accept or decline the offer sentOfferChanged doesnt fire up.