andrewda / node-steam-guide

A guide to creating Steam bots and websites using Node.js
Creative Commons Attribution 4.0 International
650 stars 130 forks source link

Callback is not a function problem #110

Open JoshuaT03 opened 3 years ago

JoshuaT03 commented 3 years ago

I've tried resolving some issues like overflowwarning and managed to fix with "npm update", however I can't find the current issue after hours of looking. Help would be appreciated! :) The console gets the error message "TypeError: callback is not a function at TradeOfferManager. (C:\Users\Admin\node_modules\steam-tradeoffer-manager\lib\index.js:75:3) at TradeOfferManager. (C:\Users\Admin\node_modules\steam-tradeoffer-manager\lib\index.js:103:3) at Request._callback (C:\Users\Admin\node_modules\steam-tradeoffer-manager\node_modules\steamcommunity\index.js:138:4) at Request.self.callback (C:\Users\Admin\node_modules\steam-tradeoffer-manager\node_modules\request\request.js:373:22) at Request.emit (node:events:394:28) at Request. (C:\Users\Admin\node_modules\steam-tradeoffer-manager\node_modules\request\request.js:1318:14) at Request.emit (node:events:406:35) at IncomingMessage. (C:\Users\Admin\node_modules\steam-tradeoffer-manager\node_modules\request\request.js:1266:12) at IncomingMessage.emit (node:events:406:35) at endReadableNT (node:internal/streams/readable:1329:12)"

My code: const SteamUser = require('steam-user'); const SteamTotp = require('steam-totp'); const SteamCommunity = require('steamcommunity'); const TradeOfferManager = require('steam-tradeoffer-manager'); const config = require('./config1.json')

const client = new SteamUser(); const community = new SteamCommunity(); const manager = new TradeOfferManager({ steam: client, community: community, language: 'en' });

const logOnOptions = { accountName: 'xxxx', password: 'xxxx', twoFactorCode: SteamTotp.generateAuthCode('xxxx') };

client.logOn(logOnOptions);

client.on('loggedOn', () => { console.log('Logged into Steam');

client.setPersona(SteamUser.EPersonaState.Online); client.gamesPlayed(730); });

client.on('webSession', (sessionid, cookies) => { manager.setCookies(cookies);

community.setCookies(cookies); community.startConfirmationChecker(10000, 'xxxx'); });

function sendRandomItem() { const partner = 'xxxx'; const appid = 730; const contextid = 2;

const offer = manager.createOffer(partner);

manager.loadInventory(appid, contextid, true, (err, myInv) => { if (err) { console.log(err); } else { const myItem = myInv[Math.floor(Math.random() * myInv.length - 1)]; offer.addMyItem(myItem);

  manager.loadUserInventory(
    partner,
    appid,
    contextid,
    true,
    (err, theirInv) => {
      if (err) {
        console.log(err);
      } else {
        const theirItem =
          theirInv[Math.floor(Math.random() * theirInv.length - 1)];
        offer.addTheirItem(theirItem);

        offer.setMessage(
          `${theirItem.name} ${myItem.name}`
        );
        offer.send((err, status) => {
          if (err) {
            console.log(err);
          } else {
            console.log(`Sent offer. Status: ${status}.`);
          }
        });
      }
    }
  );
}

}); }

manager.on('newOffer', offer => { if (offer.partner.getSteamID64() === '76561199184536525') { offer.accept((err, status) => { if (err) { console.log(err); } else { console.log(Accepted offer. Status: ${status}.); } }); } else { offer.decline(err => { if (err) { console.log(err); } else { console.log('Canceled offer.'); } }); } });

function sendRandomItem() { manager.loadInventory(730, 2, true, (err, inventory) => { if (err) { console.log(err); sendRandomItem(); } else { const offer = manager.createOffer('xxxx'); const item = inventory[Math.floor(Math.random() * inventory.length - 1)];

  offer.addMyItem(item);
  offer.setMessage(`Verify the bot is part of Steamgroup "https://steamcommunity.com/groups/xxxx" ${item.name}`);
  offer.send((err, status) => {
    if (err) {
      console.log(err);
    } else {
      console.log(`Sent offer. Status: ${status}.`);
    }
  });
}

}); }

manager.on('newOffer', offer => { if (offer.itemsToGive.length === 0) { offer.accept((err, status) => { if (err) { console.log(err); } else { console.log(Donation accepted. Status: ${status}.); } }); } else { offer.decline(err => { if (err) { console.log(err); } else { console.log('Donation declined (wanted our items).'); } }); } });

Snoopp0386 commented 3 years ago

Also need help with this