Moved check button to hypixel api
This commit is contained in:
@@ -26,8 +26,6 @@ module.exports = {
|
|||||||
|
|
||||||
const ign = interaction.options.getString("ign");
|
const ign = interaction.options.getString("ign");
|
||||||
const mojang = "https://api.mojang.com/users/profiles/minecraft/";
|
const mojang = "https://api.mojang.com/users/profiles/minecraft/";
|
||||||
// const slothPixel = "https://api.slothpixel.me/api/players/";
|
|
||||||
// const guildAPI = "https://api.slothpixel.me/api/guilds/";
|
|
||||||
const hypixel = "https://api.hypixel.net/player"
|
const hypixel = "https://api.hypixel.net/player"
|
||||||
const guildAPI = "https://api.hypixel.net/guild"
|
const guildAPI = "https://api.hypixel.net/guild"
|
||||||
const minotar = "https://minotar.net/helm/";
|
const minotar = "https://minotar.net/helm/";
|
||||||
@@ -69,18 +67,17 @@ module.exports = {
|
|||||||
const rank2 = stats.data.player.newPackageRank;
|
const rank2 = stats.data.player.newPackageRank;
|
||||||
const monthlyRank = stats.data.player.monthlyPackageRank;
|
const monthlyRank = stats.data.player.monthlyPackageRank;
|
||||||
|
|
||||||
if (rank2 === 'VIP') {
|
if (rank2 === 'VIP') {
|
||||||
var rank = "[VIP] "
|
var rank = "[VIP] "
|
||||||
} else if (rank2 === 'VIP_PLUS') {
|
} else if (rank2 === 'VIP_PLUS') {
|
||||||
var rank = "[VIP+] "
|
var rank = "[VIP+] "
|
||||||
} else if (rank2 === 'MVP') {
|
} else if (rank2 === 'MVP') {
|
||||||
var rank = "[MVP] "
|
var rank = "[MVP] "
|
||||||
} else if (rank2 === 'MVP_PLUS') {
|
} else if (rank2 === 'MVP_PLUS' && monthlyRank === 'NONE') {
|
||||||
var rank = "[MVP+] "
|
var rank = "[MVP+] "
|
||||||
} else if (rank2 === 'MVP_PLUS' && monthlyRank === 'SUPERSTAR') {
|
} else if (rank2 === 'MVP_PLUS' && monthlyRank === 'SUPERSTAR') {
|
||||||
var rank = "[MVP++] "
|
var rank = "[MVP++] "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const guild = guildAPI + "?key=" + hypixelApiKey + "&player=" + uuid
|
const guild = guildAPI + "?key=" + hypixelApiKey + "&player=" + uuid
|
||||||
const guildCheck = await fetch(guild);
|
const guildCheck = await fetch(guild);
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ const { color } = require('../../config/options.json');
|
|||||||
const fetch = require('axios');
|
const fetch = require('axios');
|
||||||
const guildapp = require('../../schemas/guildAppSchema.js');
|
const guildapp = require('../../schemas/guildAppSchema.js');
|
||||||
const { bwfdkr, bwstars, bwwins, duelswins, swstars } = require('../../config/reqs.json');
|
const { bwfdkr, bwstars, bwwins, duelswins, swstars } = require('../../config/reqs.json');
|
||||||
|
const env = require("dotenv").config();
|
||||||
|
const hypixelApiKey = process.env.HYPIXELAPIKEY;
|
||||||
|
const { getExactLevel, skywarsLevel, getLevelForExp } = require("../../utils/functions.js");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'checkstats',
|
name: 'checkstats',
|
||||||
@@ -20,50 +23,90 @@ module.exports = {
|
|||||||
const uuid = guildappdata.uuid;
|
const uuid = guildappdata.uuid;
|
||||||
|
|
||||||
const mojang = "https://api.mojang.com/user/profile/"
|
const mojang = "https://api.mojang.com/user/profile/"
|
||||||
const slothPixel = "https://api.slothpixel.me/api/players/";
|
const hypixel = "https://api.hypixel.net/player"
|
||||||
const guildAPI = "https://api.slothpixel.me/api/guilds/"
|
const guildAPI = "https://api.hypixel.net/guild"
|
||||||
const minotar = "https://minotar.net/helm/";
|
const minotar = "https://minotar.net/helm/";
|
||||||
const embedColor = Number(color.replace("#", "0x"));
|
const embedColor = Number(color.replace("#", "0x"));
|
||||||
|
|
||||||
const userCheck = await fetch(mojang + uuid);
|
const userCheck = await fetch(mojang + uuid);
|
||||||
const ign = userCheck.data.name;
|
const ign = userCheck.data.name;
|
||||||
|
const head = minotar + ign;
|
||||||
|
|
||||||
try {
|
const player = hypixel + "?key=" + hypixelApiKey + "&uuid=" + uuid
|
||||||
await fetch(slothPixel + uuid);
|
const stats = await fetch(player);
|
||||||
} catch (error) {
|
|
||||||
|
if (!stats.data.player) {
|
||||||
interaction.editReply({
|
interaction.editReply({
|
||||||
embeds: [{
|
embeds: [{
|
||||||
description: "That player hasn't played Hypixel before.",
|
description: "That player hasn't played Hypixel before.",
|
||||||
color: embedColor
|
color: embedColor
|
||||||
}]
|
}]
|
||||||
})
|
});
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const stats = await fetch(slothPixel + uuid);
|
const rank2 = stats.data.player.newPackageRank;
|
||||||
const head = minotar + ign;
|
const monthlyRank = stats.data.player.monthlyPackageRank;
|
||||||
|
|
||||||
const rank_formatted = stats.data.rank_formatted
|
if (rank2 === 'VIP') {
|
||||||
const rank2 = rank_formatted.replace(/&[0-9a-fk-or]/g, "")
|
var rank = "[VIP] "
|
||||||
|
} else if (rank2 === 'VIP_PLUS') {
|
||||||
|
var rank = "[VIP+] "
|
||||||
|
} else if (rank2 === 'MVP') {
|
||||||
|
var rank = "[MVP] "
|
||||||
|
} else if (rank2 === 'MVP_PLUS' && monthlyRank === 'NONE') {
|
||||||
|
var rank = "[MVP+] "
|
||||||
|
} else if (rank2 === 'MVP_PLUS' && monthlyRank === 'SUPERSTAR') {
|
||||||
|
var rank = "[MVP++] "
|
||||||
|
}
|
||||||
|
|
||||||
if (rank2 === "") {
|
const guild = guildAPI + "?key=" + hypixelApiKey + "&player=" + uuid
|
||||||
var rank = ""
|
const guildCheck = await fetch(guild);
|
||||||
|
|
||||||
|
if (!guildCheck.data.guild) {
|
||||||
|
var guildName = "None";
|
||||||
} else {
|
} else {
|
||||||
var rank = rank2 + " "
|
var guildName = guildCheck.data.guild.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (!guildCheck.data.guild) {
|
||||||
const guildCheck = await fetch(guildAPI + uuid)
|
var guildTag = ""
|
||||||
var guildName = guildCheck.data.name
|
} else if (!guildCheck.data.guild.tag) {
|
||||||
} catch (error) {
|
var guildTag = ""
|
||||||
var guildName = "None"
|
} else {
|
||||||
|
var guildTag = " [" + guildCheck.data.guild.tag + "]"
|
||||||
}
|
}
|
||||||
|
|
||||||
const hsbwstars = stats.data.stats.BedWars.level
|
//bedwars level
|
||||||
const hsbwfkdr = stats.data.stats.BedWars.final_k_d
|
const hsbwexp = stats.data.player.stats.Bedwars.Experience;
|
||||||
const hsbwwins = stats.data.stats.BedWars.wins
|
const hsbwstars = getLevelForExp(hsbwexp);
|
||||||
const hsswstars = stats.data.stats.SkyWars.level
|
// bedwars fkdr
|
||||||
const hsduelswins = stats.data.stats.Duels.general.wins
|
const hsbwfk = stats.data.player.stats.Bedwars.final_kills_bedwars;
|
||||||
|
const hsbwfd = stats.data.player.stats.Bedwars.final_deaths_bedwars;
|
||||||
|
const hsbwfkdr = hsbwfk / hsbwfd;
|
||||||
|
// bedwars wins
|
||||||
|
const hsbwwins = stats.data.player.stats.Bedwars.wins_bedwars;
|
||||||
|
// skywars level
|
||||||
|
const hsswexp = stats.data.player.stats.SkyWars.skywars_experience;
|
||||||
|
const hsswstars = skywarsLevel(hsswexp);
|
||||||
|
// skywars kdr
|
||||||
|
const hsswkills = stats.data.player.stats.SkyWars.kills;
|
||||||
|
const hsswdeaths = stats.data.player.stats.SkyWars.deaths;
|
||||||
|
const hsswkd = hsswkills / hsswdeaths;
|
||||||
|
//skywars wins
|
||||||
|
const hsswwins = stats.data.player.stats.SkyWars.wins;
|
||||||
|
// dueks kdr
|
||||||
|
const hsduelskills = stats.data.player.stats.Duels.kills
|
||||||
|
const hsduelsdeaths = stats.data.player.stats.Duels.deaths
|
||||||
|
const hsduelskd = hsduelskills / hsduelsdeaths
|
||||||
|
// duels wins
|
||||||
|
const hsduelswins = stats.data.player.stats.Duels.wins;
|
||||||
|
// duels wlr
|
||||||
|
const hsduelslosses = stats.data.player.stats.Duels.losses;
|
||||||
|
const hsduelswlr = hsduelswins / hsduelslosses;
|
||||||
|
// network level
|
||||||
|
const hypixelExp = stats.data.player.networkExp;
|
||||||
|
const level = getExactLevel(hypixelExp);
|
||||||
|
|
||||||
if (hsbwstars < bwstars || hsbwfkdr < bwfdkr || hsbwwins < bwwins) {
|
if (hsbwstars < bwstars || hsbwfkdr < bwfdkr || hsbwwins < bwwins) {
|
||||||
var bwtitle = "<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements."
|
var bwtitle = "<a:cross_a:1087808606897983539> This player does not meet the BedWars requirements."
|
||||||
@@ -83,24 +126,14 @@ module.exports = {
|
|||||||
var duelstitle = "<a:check_a:1087808632172847134> This player meets the Duels requirements."
|
var duelstitle = "<a:check_a:1087808632172847134> This player meets the Duels requirements."
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
const guildCheck = await fetch(guildAPI + uuid)
|
|
||||||
const tag_formatted = guildCheck.data.tag_formatted
|
|
||||||
const guildTag2 = tag_formatted.replace(/&[0-9a-fk-or]/g, "")
|
|
||||||
var guildTag = " " + guildTag2
|
|
||||||
} catch (error) {
|
|
||||||
var guildTag = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
embeds: [{
|
embeds: [{
|
||||||
title: rank + stats.data.username + guildTag,
|
title: rank + stats.data.player.displayname + guildTag,
|
||||||
description: "**Network Level:** `" + stats.data.level.toString() + "`\n" +
|
description: "**Network Level:** `" +
|
||||||
"**Current Guild:** `" + guildName + "`",
|
level.toFixed(2).toString() + "`\n" +
|
||||||
|
"**Current Guild:** `" + guildName + "`",
|
||||||
color: embedColor,
|
color: embedColor,
|
||||||
thumbnail: {
|
thumbnail: { url: head },
|
||||||
url: head
|
|
||||||
},
|
|
||||||
footer: {
|
footer: {
|
||||||
text: interaction.guild.name + " | Developed by @Taken#0002",
|
text: interaction.guild.name + " | Developed by @Taken#0002",
|
||||||
icon_url: interaction.guild.iconURL()
|
icon_url: interaction.guild.iconURL()
|
||||||
@@ -108,25 +141,42 @@ module.exports = {
|
|||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: bwtitle,
|
name: bwtitle,
|
||||||
value: "**➺ Stars:** `" + stats.data.stats.BedWars.level.toString() + "`\n" +
|
value: "**➺ Stars:** `" +
|
||||||
"**➺ FKDR:** `" + stats.data.stats.BedWars.final_k_d.toString() + "`\n" +
|
hsbwstars.toFixed(2).toString() + " / " +
|
||||||
"**➺ Wins:** `" + stats.data.stats.BedWars.wins.toString() + "`"
|
bwstars.toString() + "`\n" +
|
||||||
|
"**➺ FKDR:** `" +
|
||||||
|
hsbwfkdr.toFixed(2).toString() +
|
||||||
|
" / " + bwfdkr.toString() + "`\n" +
|
||||||
|
"**➺ Wins:** `" +
|
||||||
|
hsbwwins.toString() + " / " +
|
||||||
|
bwwins.toString() + "`"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: swtitle,
|
name: swtitle,
|
||||||
value: "**➺ Stars:** `" + stats.data.stats.SkyWars.level.toFixed(2).toString() + "`\n" +
|
value:
|
||||||
"**➺ KDR:** `" + stats.data.stats.SkyWars.kill_death_ratio.toString() + "`\n" +
|
"**➺ Stars:** `" +
|
||||||
"**➺ Wins:** `" + stats.data.stats.SkyWars.wins.toString() + "`"
|
hsswstars.toFixed(2).toString() +
|
||||||
|
" / " + swstars.toString() + "`\n" +
|
||||||
|
"**➺ KDR:** `" +
|
||||||
|
hsswkd.toFixed(2).toString() +
|
||||||
|
"`\n" +
|
||||||
|
"**➺ Wins:** `" +
|
||||||
|
hsswwins.toString() + "`"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: duelstitle,
|
name: duelstitle,
|
||||||
value: "**➺ Wins:** `" + stats.data.stats.Duels.general.wins.toString() + "`\n" +
|
value: "**➺ Wins:** `" +
|
||||||
"**➺ KDR:** `" + stats.data.stats.Duels.general.kd_ratio.toFixed(2).toString() + "`\n" +
|
hsduelswins.toString() +
|
||||||
"**➺ WLR:** `" + stats.data.stats.Duels.general.win_loss_ratio.toFixed(2).toString() + "`"
|
" / " + duelswins.toString() + "`\n" +
|
||||||
|
"**➺ KDR:** `" +
|
||||||
|
hsduelskd.toFixed(2).toString() +
|
||||||
|
"`\n" +
|
||||||
|
"**➺ WLR:** `" +
|
||||||
|
hsduelswlr.toFixed(2).toString() +
|
||||||
|
"`"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}]
|
}]
|
||||||
|
});
|
||||||
})
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user