This commit is contained in:
2023-03-20 17:49:49 +01:00
parent 6b0a73ee32
commit acb6721dc3
2 changed files with 37 additions and 29 deletions

View File

@@ -1,7 +1,7 @@
const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require('discord.js'); const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require('discord.js');
const { hypixelApiKey } = require('../config.json'); const { hypixelApiKey } = require('../config.json');
const { color } = require('../config/options.json'); const { color } = require('../config/options.json');
const axios = require('axios'); const fetch = require('axios');
module.exports = { module.exports = {
name: 'check', name: 'check',
@@ -20,9 +20,7 @@ module.exports = {
async execute(interaction) { async execute(interaction) {
await interaction.reply({content: "command is currently under development.", ephemeral: true}) await interaction.deferReply({})
// await interaction.deferReply();
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/"
@@ -31,28 +29,42 @@ module.exports = {
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 axios.get(mojang + ign); if (!ign) {
await interaction.editReply('Please provide a player\'s IGN.')
return
}
try {
await fetch(mojang + ign);
} catch (error) {
interaction.editReply('That player doesn\'t exist. [Mojang]')
return
}
const userCheck = await fetch(mojang + ign);
const userUUID = userCheck.data.id; const userUUID = userCheck.data.id;
const stats = await axios.get(slothPixel + userUUID); const stats = await fetch(slothPixel + userUUID);
const guildCheck = await axios.get(guildAPI + userUUID); const guildCheck = guildAPI + userUUID
const head = minotar + ign; const head = minotar + ign;
if (!ign) {
interaction.editReply('Please provide a player\'s IGN.')
return
}
if (!stats.data.uuid) { if (!stats.data.uuid) {
interaction.reply('That player doesn\'t exist. [Hypixel]') interaction.editReply('That player doesn\'t exist. [Hypixel]')
return return
} }
await interaction.reply({ try {
const guildCheck = await fetch(guildAPI + userUUID);
var guildName = guildCheck.data.name
} catch (error) {
var guildName = "None"
}
await interaction.editReply({
embeds: [{ embeds: [{
title: stats.data.username, title: stats.data.username,
description: "**Network Level:** `" + stats.data.level.toString() + "`\n" + description: "**Network Level:** `" + stats.data.level.toString() + "`\n" +
"**Current Guild:** `" + guildCheck.data.name + "`", "**Current Guild:** `" + guildName + "`",
color: embedColor, color: embedColor,
thumbnail: { thumbnail: {
url: head url: head
@@ -82,7 +94,6 @@ module.exports = {
} }
] ]
}] }]
}) })
} }
}; };

View File

@@ -1,6 +1,8 @@
const { color } = require('../../config/options.json'); const { color } = require('../../config/options.json');
const { dev } = require('../../config.json'); const { dev } = require('../../config.json');
const fetch = require('axios'); const fetch = require('axios');
const mongoose = require('mongoose');
const guildapp = require('../../schemas/guildAppSchema.js');
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
@@ -17,8 +19,8 @@ module.exports = {
const embed = message.embeds[0]; const embed = message.embeds[0];
const applicantId = embed.footer.text.split(" ")[1] const applicantId = embed.footer.text.split(" ")[1]
const filePath = path.join(__dirname, `../../apps/guild/${applicantId}`); const guildappdata = await guildapp.findOne({ userID: applicantId })
const uuid = fs.readFileSync(filePath, 'utf8'); 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 slothPixel = "https://api.slothpixel.me/api/players/";
@@ -28,22 +30,17 @@ module.exports = {
const userCheck = await fetch(mojang + uuid); const userCheck = await fetch(mojang + uuid);
const ign = userCheck.data.name; const ign = userCheck.data.name;
const guildCheck = await fetch(guildAPI + uuid);
const stats = await fetch(slothPixel + uuid); const stats = await fetch(slothPixel + uuid);
const head = minotar + ign; const head = minotar + ign;
if (!userCheck.data.id) { try {
interaction.editReply('That player doesn\'t exist. [Mojang]') const guildCheck = await fetch(guildAPI + uuid);
return var guildName = guildCheck.data.name
} catch (error) {
var guildName = "None"
} }
if (!stats.data.uuid) {
interaction.editReply('That player doesn\'t exist. [Hypixel]')
return
}
const guildName = guildCheck.data.name ?? "None"
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [{
title: stats.data.username, title: stats.data.username,