call23re

Group Robux

Jun 3rd, 2018
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Adds up the total amount of Robux in all of your groups. Made as a utility function for game devs with multiple groups.
  2.  
  3. const userid = YOUR_USER_ID;
  4. const groupurl = `https://www.roblox.com/users/profile/playergroups-json?userId=${userid}`;
  5. let Total = 0;
  6.  
  7. function GetRobux(id) {
  8.     let url = `https://www.roblox.com/my/groupadmin.aspx?gid=${id}`;
  9.     return new Promise((resolve, reject) => {
  10.         try {
  11.             fetch(url, {
  12.                 credentials: 'same-origin'
  13.             }).then((response) => response.text()).then((data) => {
  14.                 try {
  15.                     resolve(Number(data.match(/e-amount">[\d,,]*/g)[0].replace('e-amount">', '').replace(/,/g, '')));
  16.                 } catch(e) {
  17.                     resolve(0);
  18.                 };
  19.             });
  20.         } catch(e) {
  21.             resolve(0);
  22.         };
  23.     });
  24. };
  25.  
  26. fetch(groupurl).then((response) => response.json()).then(async (data) => {
  27.     for(let group of data.Groups) {
  28.         let Amount = await GetRobux(group.Id);
  29.         Total += Amount;
  30.     };
  31.     console.log('Total: ' + new Intl.NumberFormat().format(Total) + ' ($' + Total * 0.0035 + ')');
  32. });
Advertisement
Add Comment
Please, Sign In to add comment