Added new functions
This commit is contained in:
@@ -1,24 +1,15 @@
|
||||
const { guildLevel } = require("../../utils/utils.js");
|
||||
const { guildLevel, getUUID, getIGN, getPlayer, getGuild, getHeadURL } = require("../../utils/utils.js");
|
||||
const { color } = require("../../config/options.json");
|
||||
const apikey = process.env.HYPIXELAPIKEY;
|
||||
const fetch = require("axios");
|
||||
|
||||
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
|
||||
|
||||
async function guildMember(interaction) {
|
||||
const ign = interaction.options.getString("ign");
|
||||
|
||||
const embedColor = Number(color.replace("#", "0x"));
|
||||
const mojang = "https://api.mojang.com/users/profiles/minecraft/";
|
||||
const hypixel = "https://api.hypixel.net/player";
|
||||
const guild = "https://api.hypixel.net/guild";
|
||||
const minotar = "https://minotar.net/helm/";
|
||||
|
||||
try {
|
||||
const mojangReq = await fetch(mojang + ign);
|
||||
var uuid = mojangReq.data.id;
|
||||
} catch (err) {
|
||||
return interaction.editReply({
|
||||
const uuid = await getUUID(ign);
|
||||
if (!uuid) {
|
||||
interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
description: "This user does not exist",
|
||||
@@ -32,15 +23,8 @@ async function guildMember(interaction) {
|
||||
});
|
||||
}
|
||||
|
||||
const head = minotar + ign;
|
||||
const player = await fetch(hypixel, {
|
||||
params: {
|
||||
key: apikey,
|
||||
uuid: uuid,
|
||||
},
|
||||
});
|
||||
|
||||
if (!player.data.player) {
|
||||
const player = await getPlayer(uuid);
|
||||
if (!player) {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
@@ -74,14 +58,8 @@ async function guildMember(interaction) {
|
||||
var rank = "[MVP++] ";
|
||||
}
|
||||
|
||||
const guildCheck = await fetch(guild, {
|
||||
params: {
|
||||
key: apikey,
|
||||
player: uuid,
|
||||
},
|
||||
});
|
||||
|
||||
if (!guildCheck.data.guild) {
|
||||
const guild = await getGuild(uuid);
|
||||
if (!guild) {
|
||||
await interaction.editReply({
|
||||
embeds: [
|
||||
{
|
||||
@@ -99,34 +77,10 @@ async function guildMember(interaction) {
|
||||
});
|
||||
}
|
||||
|
||||
const guildCreationMS = guildCheck.data.guild.created;
|
||||
const guildCreationTime = new Date(guildCreationMS);
|
||||
const guildCreationDate = guildCreationTime.getDate();
|
||||
const guildCreationMonth = guildCreationTime.getMonth() + 1;
|
||||
const guildCreationYear = guildCreationTime.getFullYear();
|
||||
const guildCreationHours = guildCreationTime.getHours();
|
||||
const guildCreationMinutes = guildCreationTime.getMinutes();
|
||||
const guildCreationSeconds = guildCreationTime.getSeconds();
|
||||
const guildName = guild.name;
|
||||
const guildTag = " [" + guild.tag + "]" ?? "";
|
||||
|
||||
const guildCreation =
|
||||
guildCreationDate +
|
||||
"." +
|
||||
guildCreationMonth +
|
||||
"." +
|
||||
guildCreationYear +
|
||||
" " +
|
||||
guildCreationHours +
|
||||
":" +
|
||||
guildCreationMinutes +
|
||||
":" +
|
||||
guildCreationSeconds;
|
||||
|
||||
const guildName = guildCheck.data.guild.name;
|
||||
const guildTag = " [" + guildCheck.data.guild.tag + "]" ?? "";
|
||||
const guildExp = guildCheck.data.guild.exp;
|
||||
const guildLvl = guildLevel(guildExp);
|
||||
|
||||
const guildMembers = guildCheck.data.guild.members;
|
||||
const guildMembers = guild.members;
|
||||
const guildMember = guildMembers.find((member) => member.uuid === uuid);
|
||||
const guildRank = guildMember.rank;
|
||||
const memberGexp = guildMember.expHistory;
|
||||
|
||||
Reference in New Issue
Block a user