drdr Posted June 30, 2022 Report Posted June 30, 2022 (edited) Good afternoon Dr McKay. I'm trying to get data after the created trade object, and I get an error My Code: const SteamTotp = require("steam-totp"); const Community = require("steamcommunity"); const TradeOfferManager = require("steam-tradeoffer-manager"); const community = new Community(); const manager = new TradeOfferManager({ community, }); const accountName = "anonymos for forum"; const accountPassword = "anonymos for forum"; const accountSharedSecret = "anonymos for forum"; const accountIdentitySecret = "anonymos for forum"; const createSession = async () => { return new Promise((resolve, reject) => { community.login( { accountName, password: accountPassword, twoFactorCode: SteamTotp.generateAuthCode(accountSharedSecret), }, async (err, sessionId, cookies, steamGuard, oAuthToken) => { if (err) { console.log(err); return resolve(null); } community.setCookies(cookies); console.log("Auth!"); return resolve(true); }, ); }); }; const checkSession = async () => { return new Promise(resolve => { community.loggedIn(async (err, loggedIn, familyView) => { if (err) { console.log("CheckSession", err); } console.log({ loggedIn, familyView }); return resolve(); }); }); }; const sendTrade = async () => { await createSession(); await checkSession(); let offer = null; const create = async () => { return new Promise(resolve => { offer = manager.createOffer(new TradeOfferManager.SteamID("anonymos for forum")); offer.setToken("anonymos for forum"); offer.addMyItem({ assetid: "anonymos for forum", appid: "252490", contextid: 2, }); console.log("Trade Created"); return resolve(); }); }; await create(); await new Promise(resolve => setTimeout(() => resolve(), 5000)); offer.getUserDetails((err, me, them) => { if (err) { console.log(err); } else { console.log({ me, them }); } }); }; sendTrade(); Error console: Auth! { loggedIn: true, familyView: false } Trade Created /app/node_modules/steam-tradeoffer-manager/lib/classes/TradeOffer.js:811 var myAvatar = body.match(new RegExp('<img src="([^"]+)"( alt="[^"]*")? data-miniprofile="' + this.manager.steamID.accountid + '">')); ^ TypeError: Cannot read property 'accountid' of null at SteamCommunity.<anonymous> (/app/node_modules/steam-tradeoffer-manager/lib/classes/TradeOffer.js:811:118) at Request._callback (/app/node_modules/steamcommunity/components/http.js:67:15) at Request.self.callback (/app/node_modules/request/request.js:185:22) at Request.emit (events.js:314:20) at Request.<anonymous> (/app/node_modules/request/request.js:1154:10) at Request.emit (events.js:314:20) at Gunzip.<anonymous> (/app/node_modules/request/request.js:1076:12) at Object.onceWrapper (events.js:420:28) at Gunzip.emit (events.js:326:22) at endReadableNT (_stream_readable.js:1241:12) [nodemon] app crashed - waiting for file changes before starting... Edited June 30, 2022 by drdr Quote
Dr. McKay Posted July 1, 2022 Report Posted July 1, 2022 You need to call setCookies on the TradeOfferManager instance. Passing a SteamCommunity to the TradeOfferManager constructor makes TradeOfferManager call setCookies on the SteamCommunity instance when you call setCookies on the manager instance, but not the other way around. Quote
drdr Posted July 1, 2022 Author Report Posted July 1, 2022 12 hours ago, Dr. McKay said: You need to call setCookies on the TradeOfferManager instance. Passing a SteamCommunity to the TradeOfferManager constructor makes TradeOfferManager call setCookies on the SteamCommunity instance when you call setCookies on the manager instance, but not the other way around. Thanks, Dr 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.