Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. var apiKey = "76refeysxx9xxhdk65hast4vdu9c99nt";
  2.  
  3. /**
  4. * Return data for datasheed, contains name, realm and average equiped ilvl
  5. *
  6. * @return Array
  7. */
  8. function getMembers() {
  9. var cache = CacheService.getDocumentCache();
  10. var array = [];
  11. try {
  12. var guildJSON = UrlFetchApp.fetch("https://eu.api.battle.net/wow/guild/Drak'thul/Goodbye%20Kitty?fields=members&locale=en_GB&apikey=" + apiKey);
  13. if (guildJSON.getResponseCode() === 200) {
  14. guild = JSON.parse(guildJSON.getContentText());
  15. for(var i = 1; i < Object.keys(guild).length; i++)
  16. {
  17. if(guild.members[i].rank === 8)
  18. {
  19.  
  20. }
  21. var toonName = guild.members[i].character.name;
  22. var toonRealm = guild.members[i].character.realm;
  23. var charIlvl = getCharIlvl(toonName, toonRealm);
  24.  
  25. array[i] = [toonName, toonRealm, charIlvl];
  26. }
  27.  
  28. }
  29.  
  30. } catch (err) {
  31. if (err) {
  32. throw err;
  33. }
  34. Utilities.sleep((Math.pow(2,n)*1000) + (Math.round(Math.random() * 1000)));
  35. }
  36.  
  37. return array;
  38. }
  39.  
  40. /**
  41. * Gets char average equiped ilvl
  42. *
  43. * @param string toonName
  44. * @param string toonRealm
  45. *
  46. * @return double
  47. */
  48. function getCharIlvl(toonName, toonRealm)
  49. {
  50. try {
  51. var charJson = UrlFetchApp.fetch("https://eu.api.battle.net/wow/character/" + toonRealm + "/" + toonName + "?fields=items&locale=en_GB&apikey=" + apiKey);
  52. if (charJson.getResponseCode() === 200) {
  53. char = JSON.parse(charJson.getContentText());
  54.  
  55. return char.items.averageItemLevelEquipped;
  56. }
  57.  
  58. } catch (err) {
  59. if (err) {
  60. throw err;
  61. }
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement