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