Skip to content

Commit

Permalink
lol
Browse files Browse the repository at this point in the history
  • Loading branch information
AxleCat284 committed Apr 19, 2024
1 parent eb6c89a commit 12d1279
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 9 deletions.
46 changes: 44 additions & 2 deletions src/discord/commands/embeds/weightEmbed.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const config = require(`../../../../config.json`);
const { addNotation, addCommas } = require(`../../../contracts/helperFunctions`);
const messages = config.messages.discord;
const { farmingWeight } = require("../../../functions/get/getWeight")
const { farmingWeight, senitherWeight } = require("../../../functions/get/getWeight")
const EMOJIS = {
PURSE_ICON: `<:Purse:1059997956784279562>`,
BOOSTER_COOKIE_ICON: `<:BOOSTER_COOKIE:1070126116846710865>`,
Expand Down Expand Up @@ -52,8 +52,50 @@ async function farmingWeight_Embed(uuid, username, profilename) {
}
}

async function SenitherWeight_Embed(profile, username, profilename) {
async function SenitherWeight_Embed(profile, username, profilename, uuid) {
try {
const weight = await senitherWeight(profile);
return {
color: 0xffa600,
title: `BBC Weight for ${username} on ${profilename}`,
URL: `https://sky.shiiyu.moe/stats/${uuid}`,
description: `${EMOJIS.SWORD_ICON} Total Weight: **${weight.total_weight}** + ${weight.totalOverflow}`,
fields: [
{
name: `${EMOJIS.MISC_ICON} Skills`,
value: weight.skills,
inline: false,
},
{
name: `${EMOJIS.BONUS_ICON} slayers`,
value: weight.slayers,
inline: false,
},
{
name: `${EMOJIS.BONUS_ICON} dungeons`,
value: weight.dungeons,
inline: false,
},
],
thumbnail: {
url: `https://api.mineatar.io/body/full/${uuid}`
},
footer: {
text: `${messages.farming_weight}`,
iconURL: `${messages.icon}`,
},
}
} catch (error) {
return {
color: 0xFF0000,
title: `An error occured while building this embed`,
description: `${EMOJIS.SWORD_ICON} ${error?.toString()}`,


}
}


}


Expand Down
13 changes: 8 additions & 5 deletions src/discord/commands/weightCommand.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const config = require("../../../config.json");
const { handleError } = require("../../functions/handle/handleError");
const { farmingWeight } = require("../../functions/get/getWeight")
const { farmingWeight_Embed } = require('./embeds/weightEmbed')
const { farmingWeight_Embed, SenitherWeight_Embed } = require('./embeds/weightEmbed')
const { getPlayer } = require("../../functions/get/getPlayer")
const messages = config.messages.discord

Expand All @@ -18,14 +18,17 @@ module.exports = {
],
execute: async (interaction, client, InteractionCreate) => {
const id = interaction.user.id;
const { uuid2, username, profilename, profileid, error } = await getPlayer(
const { uuid2, username, profilename, profileid, playerData, profileData, profile, error } = await getPlayer(
id,
interaction.options.getString("name")
);
const farming_weight_embed = await farmingWeight_Embed(uuid2, username, profilename)
await interaction.deferReply();

try {
await interaction.editReply({ embeds: [farming_weight_embed ] })
await interaction.deferReply();
const farming_weight_embed = await farmingWeight_Embed(uuid2, username, profilename)
const senither_weight_embed = await SenitherWeight_Embed(profile, username, profilename, uuid2)

await interaction.editReply({ embeds: [senither_weight_embed, farming_weight_embed ] })
} catch (error) {
const errorEmbed = handleError(error);
await interaction.editReply({ embeds: [errorEmbed] });
Expand Down
4 changes: 2 additions & 2 deletions src/functions/get/getPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ async function getPlayer(id, name) {
const { data: { data: { player } } } = await axios.get(`https://playerdb.co/api/player/minecraft/${name}`);
const { username, raw_id: uuid2 } = player;
const [ playerRes, profileRes ] = await Promise.all([
axios.get(`https://api.hypixel.net/v2/player?key=${key}&uuid=${uuid2}`),
axios.get(`https://api.hypixel.net/v2/skyblock/profiles?key=${key}&uuid=${uuid2}`)
axios.get(`https://api.hypixel.net/player?key=${key}&uuid=${uuid2}`),
axios.get(`https://api.hypixel.net/skyblock/profiles?key=${key}&uuid=${uuid2}`)
]);
if (playerRes.status !== 200 || profileRes.status !== 200) {
throw new Error(`Error getting player or profile data.`);
Expand Down

0 comments on commit 12d1279

Please sign in to comment.