MrMcShroom

Untitled

Oct 26th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const request = require('request');
  2. const hypixelfunctions = require('../hypixelfunctions.js');
  3. const statistics = require('../statistics.js');
  4. const config = require('../config.json');
  5. const MojangAPI = require('mojang-api');
  6.  
  7.  
  8.  
  9. exports.run = (client, message, args, Discord,) => {
  10.     let game = args[0];
  11.     const username = args[1];
  12.     var date = new Date();
  13.     let uuid = hypixelfunctions.validateUUID(username);
  14.     function BOROP(e, res, data) {
  15.         if(!e) {
  16.             if (res && res.statusCode === 200) {
  17.                 var data = JSON.parse(data);
  18.                 if(!data) {
  19.                     message.channel.send("This user has no stats!");
  20.                 } else {
  21.                     switch (game) {
  22.                         case "bedwars":
  23.                         case "bw":
  24.                         try {
  25.                             statistics.bedwars(data,message,uuid);
  26.                         }
  27.                         catch(err) {
  28.                             message.channel.send("This player has no bedwars Stats!");
  29.                             console.log(err)
  30.                         }
  31.                     }
  32.                 }
  33.             } else {
  34.                 message.channel.send("There was some sort of error. Sorry!")
  35.             }
  36.         } else {
  37.             console.error("Error: " + e.toString());
  38.             message.channel.send("There was some sort of error. Sorry!")
  39.         }
  40.     }
  41.     if (!username || !game) {
  42.         message.channel.send("Try it like this! `!hypixel [gametype] [username]` :)");
  43.     } else {
  44.         game = game.toLowerCase();
  45.         if (!uuid) {
  46.             MojangAPI.uuidAt(username, date, (err, res) => {
  47.                 if (err) {
  48.                     console.log(err);
  49.                     message.channel.send("There was an error, or that account/UIID doesn't exist!");
  50.                 } else {
  51.                     uuid = res.id;
  52.                     console.log(uuid + " Whut");
  53.                     request.get("https://api.hypixel.net/player?key=" + config.hypixelkey + "&uuid=" + uuid, BOROP);
  54.                 }
  55.             });
  56.         }
  57.             console.log(uuid);
  58.             request.get("https://api.hypixel.net/player?key=" + config.hypixelkey + "&uuid=" + uuid, BOROP);
  59.     }
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment