Advertisement
Azoqz

Hypixel

Mar 23rd, 2019
889
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require("discord.js");
  2. const bot = new Discord.Client({ disableEveryone: false });
  3. const fs = require('fs')
  4. let client = bot;
  5. bot.on(`ready`, () => {
  6.     console.log(`Logged in as ${bot.user.tag}!`);
  7.     bot.user.setStatus("online")
  8. });
  9. client.on('error', console.error);
  10. bot.on("message", async message => {
  11.     let prefix = `$` //يمديك تغيره لو تبي
  12.     let messageArray = message.content.split(" ");
  13.     let msg = message;
  14.     let cmd = messageArray[0];
  15.     let args = messageArray.slice(1);
  16.     if (!message.content.startsWith(prefix)) return;
  17.     if (message.content.startsWith(prefix + "hypixel")) {
  18.         const Hypixel = require('hypixel');
  19.         const Client = new Hypixel({ key: 'ادخل هايبكسل سوي /api' });
  20.         const moment = require("moment");
  21.         Client.getPlayerByUsername(args, (err, player) => {
  22.             // console.log(player)
  23.             if (player === undefined || player === null) return message.channel.send("Player not found buddy")
  24.             let rank = player.newPackageRank
  25.             let mcver = player.mcVersionRp
  26.             let lastLogout = player.lastLogout
  27.             let firstLogin = player.firstLogin
  28.             let karma = player.karma
  29.             if (mcver === undefined) {
  30.                 mcver = `\`Non\``
  31.             }
  32.             message.channel.startTyping(true)
  33.             if (!rank) rank = 'Non'
  34.             let exp = player.networkExp
  35.             var x = (Math.sqrt(exp + 15312.5) - 125 / Math.sqrt(2)) / (25 * Math.sqrt(2))
  36.             x = x.toFixed(2)
  37.             let hypixel = new Discord.RichEmbed()
  38.             if (rank === 'MVP_PLUS' && player.monthlyPackageRank !== 'SUPERSTAR') {
  39.                 rank = 'MVP+'
  40.                 hypixel.setThumbnail('https://i.imgur.com/wvXzJMA.png')
  41.             }
  42.             if (player.mostRecentMonthlyPackageRank === 'SUPERSTAR' && player.monthlyPackageRank === 'SUPERSTAR') {
  43.                 rank = 'MVP++'
  44.                 hypixel.setThumbnail('https://i.imgur.com/w3l6hGY.png')
  45.             }
  46.             if (player.rank === 'HELPER') hypixel.setThumbnail('https://i.imgur.com/xTOmY9L.png')
  47.             if (player.rank === 'MODERATOR') hypixel.setThumbnail('https://i.imgur.com/HQEZazI.png')
  48.             if (player.rank === 'ADMIN') hypixel.setThumbnail('https://i.imgur.com/wIisMcZ.png')
  49.             if (player.rank !== 'ADMIN' && player.monthlyPackageRank !== 'SUPERSTAR' && player.rank !== 'MODERATOR' && player.newPackageRank !== 'MVP_PLUS' && player.rank !== 'HELPER') {
  50.                 hypixel.setThumbnail('https://i.imgur.com/7aFEXPY.png')
  51.             }
  52.             Client.findGuildByPlayer(player.uuid)
  53.                 .then((guildId) => {
  54.                     let hi = `https://api.hypixel.net/guild?key=الأي بي اي &id=${guildId}`
  55.                     let image = `${`https://visage.surgeplay.com/full/250/${player.uuid}.png`}`
  56.                     const fetch = require('node-fetch')
  57.                     fetch(`${hi}`)
  58.                         .then(res => res.json()
  59.                             .then(json => {
  60.                                 hypixel.setTitle(`[${rank}]` + ` ${args}`)
  61.                                 hypixel.setURL(`https://hypixel.net/player/${args}`)
  62.                                 hypixel.addField('Rank', `\`${rank}\``, true)
  63.                                 hypixel.addField('Level', `\`${x}\``, true)
  64.                                 hypixel.addField('Minecraft Version', `\`${mcver}\``, true)
  65.                                 if (json.guild === undefined || !json.guild) {
  66.                                     hypixel.addField('Guild', '\`Non\`', true)
  67.                                 } else if (json.guild.name !== undefined) {
  68.                                     hypixel.addField('Guild', `[${json.guild.name}](https://hypixel.net/guilds/${json.guild.name.replace(" ", "%20")})`, true)
  69.                                 }
  70.                                 hypixel.addField('Karma', `\`${karma.toLocaleString('en')}\``, true)
  71.                                 hypixel.addField('First/Last login', `\`${moment(firstLogin).format("YYYY-MM-DD")} / ${moment(lastLogout).format("YYYY-MM-DD")}\`\n\`${moment(player.lastLogout).fromNow()}\``, true)
  72.                                 hypixel.setImage(image);
  73.                                 if (player.socialMedia !== undefined) {
  74.                                     let that = message.guild.members.find(c => c.displayName === `${player.socialMedia.links["DISCORD"].slice(0, -5)}`);
  75.                                     if (that !== null) {
  76.                                         that = message.guild.members.find(c => c.displayName === `${player.socialMedia.links["DISCORD"].slice(0, -5)}`)
  77.                                     } else if (that === null) {
  78.                                         that = `${player.socialMedia.links["DISCORD"]}`
  79.  
  80.                                     }
  81.                                     hypixel.addField("Discord", `${that}`, true)
  82.                                     hypixel.addField('Forums', `[View Forums account.](https://hypixel.net/player/${args})`, true)
  83.                                 }
  84.                                 message.channel.stopTyping(true)
  85.                                 message.channel.send(hypixel)
  86.  
  87.                             }).catch((err) => {
  88.                                 message.channel.stopTyping(true)
  89.                                 if (err) throw err;
  90.                                 return message.channel.send('Uh oh ... there must be a problem!')
  91.                             }));
  92.                 }).catch((err) => {
  93.                     message.channel.stopTyping(true)
  94.                     if (err) throw err;
  95.                     return message.channel.send('Uh oh ... there must be a problem!')
  96.                 });
  97.         })
  98.     }
  99. });
  100. client.login("login")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement