Updating applications
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
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()
|
||||
}
|
||||
]
|
||||
}]
|
||||
|
||||
})
|
||||
}
|
||||
};
|
||||
@@ -24,6 +24,41 @@ module.exports = {
|
||||
}]
|
||||
});
|
||||
|
||||
// fetch the first message in the channel and disable the buttons on it
|
||||
|
||||
const message = await channel.messages.fetch({ limit: 1 });
|
||||
const messageID = message.first().id;
|
||||
|
||||
await channel.messages.fetch(messageID).then(async (message) => {
|
||||
|
||||
await message.edit({
|
||||
components: [
|
||||
new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("guildapplicationaccept")
|
||||
.setLabel("Accept")
|
||||
.setStyle(ButtonStyle.Primary)
|
||||
.setDisabled(true)
|
||||
),
|
||||
new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("guildapplicationdeny")
|
||||
.setLabel("Deny")
|
||||
.setStyle(ButtonStyle.Danger)
|
||||
.setDisabled(true)
|
||||
),
|
||||
new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("checkstats")
|
||||
.setLabel("Check Stats")
|
||||
.setStyle(ButtonStyle.Secondary)
|
||||
.setDisabled(true)
|
||||
)
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
await interaction.reply({
|
||||
embeds: [{
|
||||
title: applicantUsername + " - Application",
|
||||
|
||||
Reference in New Issue
Block a user