Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const request = require('request');
- const hypixelfunctions = require('../hypixelfunctions.js');
- const statistics = require('../statistics.js');
- const config = require('../config.json');
- const MojangAPI = require('mojang-api');
- exports.run = (client, message, args, Discord,) => {
- let game = args[0];
- const username = args[1];
- var date = new Date();
- let uuid = hypixelfunctions.validateUUID(username);
- if (!username || !game) {
- message.channel.send("Try it like this! `!hypixel [gametype] [username]` :)");
- } else {
- game = game.toLowerCase();
- if (!uuid) {
- MojangAPI.uuidAt(username, date, (err, res) => {
- if (err) {
- console.log(err);
- message.channel.send("There was an error, or that account/UIID doesn't exist!");
- } else {
- uuid = res.id;
- console.log(uuid + " Whut");
- }
- });
- }
- console.log(uuid);
- request.get("https://api.hypixel.net/player?key=" + config.hypixelkey + "&uuid=" + uuid, function(e, res, data) {
- console.log(data);
- console.log("https://api.hypixel.net/player?key=" + config.hypixelkey + "&uuid=" + uuid)
- if(!e) {
- if (res && res.statusCode === 200) {
- var data = JSON.parse(data);
- if(!data) {
- message.channel.send("This user has no stats!");
- } else {
- switch (game) {
- case "bedwars":
- case "bw":
- try {
- statistics.bedwars(data,message,uuid);
- }
- catch(err) {
- message.channel.send("This player has no bedwars Stats!");
- console.log(err)
- }
- }
- }
- } else {
- message.channel.send("There was some sort of error. Sorry!")
- }
- } else {
- console.error("Error: " + e.toString());
- message.channel.send("There was some sort of error. Sorry!")
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment