xLeeJYx Posted June 3, 2017 Report Posted June 3, 2017 This is my current projecthttps://github.com/xLeeJYx/backpacktf-automatic-pro i plan to increase more functions on the bot My question is this : how do i make node-steamcommunity comment on profile's user when the trade succeded is there something like manager.on('succes'){ postUserComment(offer.partner.toString(), "Thanks for trading with me!")} Quote
Dr. McKay Posted June 3, 2017 Report Posted June 3, 2017 If you're accepting incoming offers, listen for the receivedOfferChanged event and do something when the state is Accepted. If you're sending offers, listen for the sentOfferChanged event and do something when the state is Accepted. Quote
xLeeJYx Posted June 4, 2017 Author Report Posted June 4, 2017 (edited) Umm what should code in there, i want it to comment when incomming trade was accepted i tried this const SteamCommunity = require('steamcommunity'); const TradeOfferManager = require('steam-tradeoffer-manager'); var community = new SteamCommunity(); var manager = new TradeOfferManager(); manager.on(receivedOfferChanged, (comment) => { community.postUserComment(offer.partner.toString(), 'Test'); });it didnt comment on the profile though Edited June 4, 2017 by xLeeJYx Quote
Dr. McKay Posted June 4, 2017 Report Posted June 4, 2017 You need quotes around receivedOfferChanged. That should have just crashed without doing anything. Quote
xLeeJYx Posted June 4, 2017 Author Report Posted June 4, 2017 (edited) hmm this is the whole code, still couldnt fix it, im new to coding please don't judge. It still wont post the comment it gave this error... C:\Users\JingYong-PC\Desktop\comment\test.js:40 community.postUserComment(manager.offer.partner.toString(), 'Test'); ^ TypeError: Cannot read property 'partner' of undefined at TradeOfferManager.manager.on (C:\Users\JingYong-PC\Desktop\comment\test.js:40:40) at emitTwo (events.js:106:13) at TradeOfferManager.emit (events.js:191:7) at received.forEach (C:\Users\JingYong-PC\Desktop\comment\node_modules\steam-tradeoffer-manager\lib\polling.js:237:10) at Array.forEach (native) at getOffers (C:\Users\JingYong-PC\Desktop\comment\node_modules\steam-tradeoffer-manager\lib\polling.js:219:12) at Helpers.checkNeededDescriptions (C:\Users\JingYong-PC\Desktop\comment\node_modules\steam-tradeoffer-manager\lib\index.js:359:4) at Object.exports.checkNeededDescriptions (C:\Users\JingYong-PC\Desktop\comment\node_modules\steam-tradeoffer-manager\lib\helpers.js:90:3) at _apiCall (C:\Users\JingYong-PC\Desktop\comment\node_modules\steam-tradeoffer-manager\lib\index.js:350:11) at SteamCommunity._community.httpRequest (C:\Users\JingYong-PC\Desktop\comment\node_modules\steam-tradeoffer-manager\lib\webapi.js:54:3) Press any key to continue . . . //Required modules const SteamCommunity = require('steamcommunity'); const TradeOfferManager = require('steam-tradeoffer-manager'); const SteamTotp = require('steam-totp'); const SteamUser = require('steam-user'); //Config var config = require('./config.json') var client = new SteamUser(); var community = new SteamCommunity(); var manager = new TradeOfferManager({ steam: client, community: community, language: 'en', }); client.logOn( { accountName: config.username, password: config.password, twoFactorCode: SteamTotp.generateAuthCode(config.shared_secret) }); client.on('loggedOn', () => { console.log('Logged in to steam !'); client.setPersona(SteamUser.Steam.EPersonaState.Online); client.gamesPlayed(440); }); client.on('webSession', (sessionid, cookies) => { manager.setCookies(cookies); community.setCookies(cookies); community.startConfirmationChecker(10000, config.identity_secret); }); manager.on('receivedOfferChanged', () => { community.postUserComment(manager.offer.partner.toString(), 'Test'); }); Edited June 4, 2017 by xLeeJYx Quote
Dr. McKay Posted June 5, 2017 Report Posted June 5, 2017 manager.offer doesn't exist. You want this: manager.on('receivedOfferChanged', (offer) => { community.postUserComment(offer.partner.toString(), 'Test'); }); 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.