Files
illegitimate-bot/events/buttons/checkstats.js
2023-03-20 17:49:49 +01:00

81 lines
3.2 KiB
JavaScript

const { color } = require('../../config/options.json');
const { dev } = require('../../config.json');
const fetch = require('axios');
const mongoose = require('mongoose');
const guildapp = require('../../schemas/guildAppSchema.js');
const fs = require('fs');
const path = require('path');
module.exports = {
name: 'checkstats',
description: 'Check your stats.',
type: 'button',
async execute(interaction) {
await interaction.deferReply();
const message = interaction.message;
const embed = message.embeds[0];
const applicantId = embed.footer.text.split(" ")[1]
const guildappdata = await guildapp.findOne({ userID: applicantId })
const uuid = guildappdata.uuid;
const mojang = "https://api.mojang.com/user/profile/"
const slothPixel = "https://api.slothpixel.me/api/players/";
const guildAPI = "https://api.slothpixel.me/api/guilds/"
const minotar = "https://minotar.net/helm/";
const embedColor = Number(color.replace("#", "0x"));
const userCheck = await fetch(mojang + uuid);
const ign = userCheck.data.name;
const stats = await fetch(slothPixel + uuid);
const head = minotar + ign;
try {
const guildCheck = await fetch(guildAPI + uuid);
var guildName = guildCheck.data.name
} catch (error) {
var guildName = "None"
}
await interaction.editReply({
embeds: [{
title: stats.data.username,
description: "**Network Level:** `" + stats.data.level.toString() + "`\n" +
"**Current Guild:** `" + guildName + "`",
color: embedColor,
thumbnail: {
url: head
},
footer: {
text: interaction.guild.name + " | Developed by @Taken#0002",
icon_url: interaction.guild.iconURL()
},
fields: [
{
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() + "`"
},
{
name: "**Duels**",
value: "**➺ Wins:** `" + stats.data.stats.Duels.general.wins.toString() + "`\n" +
"**➺ KDR:** `" + stats.data.stats.Duels.general.kd_ratio.toFixed(2).toString() + "`\n" +
"**➺ WLR:** `" + stats.data.stats.Duels.general.win_loss_ratio.toFixed(2).toString() + "`"
}
]
}]
})
}
};