Andrei Elvis Posted October 6 Report Posted October 6 (edited) Hello! I've been facing an issue. The bot was used to work before, but now it is not working. I've also tried to create a new code from scratch (maybe the old code was wrong) but still, the same result. There is no console log, nothing, about the `sentOfferChanged` event.. Here is my code: // Required packages const SteamTotp = require('steam-totp'); const SteamCommunity = require('steamcommunity'); const TradeOfferManager = require('steam-tradeoffer-manager'); // Steam credentials const username = 'xxx'; const password = 'xxx'; const sharedSecret = 'xxx'; // Target trade link (replace with the actual trade offer link of the user) const tradeOfferURL = 'https://steamcommunity.com/tradeoffer/new/?partner=xxx&token=xxx'; // SteamCommunity and TradeOfferManager instances const community = new SteamCommunity(); const manager = new TradeOfferManager({ community: community, domain: 'localhost', language: 'en', pollInterval: 10000 }); // Steam App ID and Context ID for CS:GO const appid = 730; const contextid = 2; // Log in and send a trade offer function loginAndSendTradeOffer() { console.log("Logging in to Steam..."); const authCode = SteamTotp.generateAuthCode(sharedSecret); community.login({ accountName: username, password: password, twoFactorCode: authCode }, (err, sessionID, cookies, steamguard) => { if (err) { console.log("Failed to login:", err); return; } console.log("Successfully logged in!"); manager.on('debug', console.log) manager.setCookies(cookies, (err) => { if (err) { console.log("Failed to set cookies:", err); return; } console.log("Cookies set, fetching inventory..."); manager.getUserInventoryContents('xxx', appid, contextid, true, (err, inventory) => { if (err) { console.log("Failed to fetch partner's inventory:", err); return; } if (inventory.length === 0) { console.log("Partner's inventory is empty, no items to trade."); return; } console.log(`Found ${inventory.length} items in partner's inventory. Picking the first item...`); const firstItem = inventory[0]; const offer = manager.createOffer(tradeOfferURL); offer.addTheirItem({ appid: appid, contextid: contextid, assetid: firstItem.assetid }); offer.send((err, status) => { if (err) { console.log("Failed to send offer:", err); return; } console.log("Trade offer sent successfully! Status:", status); }); }); }); }); } manager.on('sentOfferChanged', (offer, oldState) => { console.log(`Trade offer #${offer.id} changed from ${oldState} to ${offer.state}.`); switch (offer.state) { case TradeOfferManager.ETradeOfferState.Accepted: console.log('The trade offer was accepted!'); break; case TradeOfferManager.ETradeOfferState.Declined: console.log('The trade offer was declined.'); break; case TradeOfferManager.ETradeOfferState.Canceled: console.log('The trade offer was canceled.'); break; case TradeOfferManager.ETradeOfferState.InvalidItems: console.log('The trade offer contained invalid items.'); break; case TradeOfferManager.ETradeOfferState.Countered: console.log('The trade offer was countered by the other party.'); break; default: console.log('Trade offer status updated.'); break; } }); loginAndSendTradeOffer(); And these are my logs, after having it running for few time ( after I've declined the offer ) Logging in to Steam... Successfully logged in! Doing trade offer poll since 1 (full update) Cookies set, fetching inventory... Trade offer poll succeeded in 361 ms Found 39 items in partner's inventory. Picking the first item... Trade offer sent successfully! Status: sent Doing trade offer poll since 0 Trade offer poll succeeded in 260 ms Doing trade offer poll since 0 Trade offer poll succeeded in 230 ms Doing trade offer poll since 0 Trade offer poll succeeded in 257 ms Doing trade offer poll since 0 Trade offer poll succeeded in 241 ms Doing trade offer poll since 0 Trade offer poll succeeded in 246 ms Doing trade offer poll since 0 Trade offer poll succeeded in 247 ms Doing trade offer poll since 0 Trade offer poll succeeded in 266 ms Doing trade offer poll since 0 Trade offer poll succeeded in 416 ms Doing trade offer poll since 0 Trade offer poll succeeded in 235 ms Doing trade offer poll since 0 Trade offer poll succeeded in 228 ms Doing trade offer poll since 0 Trade offer poll succeeded in 281 ms Doing trade offer poll since 1 (full update) Trade offer poll succeeded in 294 ms Doing trade offer poll since 0 Trade offer poll succeeded in 245 ms Doing trade offer poll since 0 Trade offer poll succeeded in 236 ms Doing trade offer poll since 0 Trade offer poll succeeded in 378 ms What's wrong? I've used another steam account for this and it's the same result. It is like I am doing something wrong.. what am I doing wrong? Thanks!! Edited October 6 by Andrei Elvis Quote
Dr. McKay Posted October 7 Report Posted October 7 You need to enable the useAccessToken option or trades containing CS2 items won't appear. Andrei Elvis 1 Quote
Andrei Elvis Posted October 7 Author Report Posted October 7 12 hours ago, Dr. McKay said: You need to enable the useAccessToken option or trades containing CS2 items won't appear. Thanks, that was the fix! <3 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.