Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Promise = require ('bluebird');
  2. var SteamApi = require('steam-api');
  3. var steam = require('steam-web');
  4. var STEAM_API_KEY = "48CCAFE1F09793F723FF03F306169734";
  5. var optionalSteamId = '76561198058632219';
  6.  
  7. var user = new SteamApi.User(STEAM_API_KEY, optionalSteamId);
  8. var s = new steam({
  9.     apiKey: '48CCAFE1F09793F723FF03F306169734',
  10.     format: 'json'
  11. });
  12.  
  13. let promiseGetFriendListIds = function () {
  14.  
  15.     return new Promise(function (resolve, reject) {
  16.         user.GetFriendList(optionalRelationship = 'all', optionalSteamId).done(function (result) {
  17.             let ArrayWithId = [];
  18.             for (let i in result) {
  19.                 ArrayWithId.push(result[i]['steamId']);
  20.             }
  21.             resolve(ArrayWithId);
  22.         });
  23.     });
  24. };
  25. //ArrayWithId length = 100
  26. let promiseGetAllSteamIds = function (ArrayWithId) {
  27.     return new Promise(function (resolve,reject) {
  28.         let NextArrayWithId  = [];
  29.         for (let i = 0; i < ArrayWithId.length ; i++) {
  30.  
  31.             setTimeout( function () {
  32.                 s.getFriendList({
  33.                     steamid: ArrayWithId[i],
  34.                     relationship: 'all',
  35.                     callback: function(err,res) {
  36.                         for (var j in res) {
  37.                               NextArrayWithId.push(res[j].friends);
  38.                               console.log(res[j]);
  39.                           }
  40.  
  41.  
  42.                         resolve(res);
  43.  
  44.                     },
  45.                 })
  46.  
  47.                 //user.GetFriendList(optionalRelationship = 'all', ArrayWithId[i]).done(function (res) {
  48.  
  49.                 //})
  50.             },1000)
  51.         }
  52.     })
  53. }
  54.  
  55.  
  56. promiseGetFriendListIds()
  57.     .then(promiseGetAllSteamIds)
  58.     .then(function(res){
  59.         console.log(res);
  60.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement