Files
illegitimate-bot/events/buttons/checkstats.js
2023-03-13 11:56:37 +01:00

83 lines
2.8 KiB
JavaScript

const { color } = require('../../options.json');
const { dev } = require('../../config.json');
const fetch = require('axios');
const fs = require('fs');
const path = require('path');
module.exports = {
name: 'checkstats',
description: 'Check your stats.',
type: 'button',
async execute(interaction) {
const channel = interaction.channel;
const applicantId = await channel.topic
const filePath = path.join(__dirname, `../../applications/${applicantId}`);
const ign = fs.readFileSync(filePath, 'utf8');
const mojang = "https://api.mojang.com/users/profiles/minecraft/"
const slothPixel = "https://api.slothpixel.me/api/players/";
const minotar = "https://minotar.net/helm/";
const embedColor = Number(color.replace("#", "0x"));
const userCheck = await fetch(mojang + ign);
const stats = await fetch(slothPixel + ign);
const head = minotar + ign;
if (interaction.user.id !== dev) {
interaction.reply('This command is currently under development.')
return
}
if (!ign) {
interaction.reply('Please provide a player\'s IGN.')
return
}
if (!userCheck.data.id) {
interaction.reply('That player doesn\'t exist. [Mojang]')
return
}
if (!stats.data.uuid) {
interaction.reply('That player doesn\'t exist. [Hypixel]')
return
}
await interaction.reply({
embeds: [{
title: stats.data.username,
description: "**Stats:**",
color: embedColor,
thumbnail: {
url: head
},
footer: {
text: "Developed by @Taken#0002"
},
fields: [
{
name: "**Network Level**",
value: stats.data.level.toString(),
},
{
name: "**Bedwars**",
value: "**Stars:** " + stats.data.stats.BedWars.level.toString() + "\n" +
"**FKDR:** " + stats.data.stats.BedWars.final_k_d.toString() + "\n" +
"**Wins:** " + stats.data.stats.BedWars.wins.toString()
},
{
name: "**Skywars**",
value: "**Stars:** " + stats.data.stats.SkyWars.level.toFixed(2).toString() + "\n" +
"**KDR**: " + stats.data.stats.SkyWars.kill_death_ratio.toString() + "\n" +
"**Wins:** " + stats.data.stats.SkyWars.wins.toString()
}
]
}]
})
}
};