-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SkyStats Nightly 1.4.6 Weight command beta +farmingWeight() +senitherWeight() +Sanitization for both +weightCommand.js Note that weight command is not finished and this is only the framework TODO Buttons and switching
- Loading branch information
1 parent
6e51339
commit 488c564
Showing
14 changed files
with
227 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,4 @@ class CommandHandler { | |
} | ||
} | ||
|
||
module.exports = CommandHandler | ||
module.exports = CommandHandler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const config = require(`../../../../config.json`); | ||
const { addNotation, addCommas } = require(`../../../contracts/helperFunctions`); | ||
const messages = config.messages.discord; | ||
const { farmingWeight } = require("../../../functions/get/getWeight") | ||
const EMOJIS = { | ||
PURSE_ICON: `<:Purse:1059997956784279562>`, | ||
BOOSTER_COOKIE_ICON: `<:BOOSTER_COOKIE:1070126116846710865>`, | ||
SOULBOUND_ICON: `<:IRON_INGOT:1070126498616455328>`, | ||
BANK_ICON: `<:Bank:1059664677606531173>`, | ||
SACK_ICON: `<:sacks:1059664698095710388>`, | ||
ARMOR_ICON: `<:DIAMOND_CHESTPLATE:1061454753357377586>`, | ||
EQUIPMENT_ICON: `<:Iron_Chestplate:1061454825839144970>`, | ||
WARDROBE_ICON: `<:ARMOR_STAND:1061454861071298620>`, | ||
INVENTORY_ICON: `<:CHEST:1061454902049656993>`, | ||
ENDER_CHEST_ICON: `<:ENDER_CHEST:1061454947931140106>`, | ||
SWORD_ICON: "<:sword:1060045450897539122>", | ||
STORAGE_ICON: `<:storage:1059664802701656224>`, | ||
MUSEUM_ICON: `<:LEATHER_CHESTPLATE:1134874048048935012>`, | ||
PET_ICON: `<:Spawn_Null:1061455273224577024>`, | ||
BONUS_ICON: "<:carrot:1072129687427498012>", | ||
ACCESSORY_BAG_ICON: `<:HEGEMONY_ARTIFACT:1061455309983461486>`, | ||
PERSONAL_VAULT_ICON: `<:item_2654:1061455349338615859>`, | ||
MISC_ICON: `<:wheat:1059664236038590584>`, | ||
} | ||
|
||
async function farmingWeight_Embed(uuid, username, profilename) { | ||
const weight = await farmingWeight(uuid) | ||
return { | ||
color: 0xffa600, | ||
title: `Farming Weight for ${username} on ${profilename}`, | ||
URL: `https://sky.shiiyu.moe/stats/${uuid}`, | ||
description: `${EMOJIS.SWORD_ICON} Total Weight: **${weight.total_weight}**`, | ||
fields: [ | ||
{ | ||
name: `${EMOJIS.MISC_ICON} Crops`, | ||
value: weight.items.crop_weight, | ||
inline: false, | ||
}, | ||
{ | ||
name: `${EMOJIS.BONUS_ICON} Bonuses`, | ||
value: weight.items.bonus_weight, | ||
inline: false, | ||
}, | ||
], | ||
thumbnail: { | ||
url: `https://api.mineatar.io/body/full/${uuid}` | ||
}, | ||
footer: { | ||
text: `${messages.farming_weight}`, | ||
iconURL: `${messages.icon}`, | ||
}, | ||
} | ||
} | ||
|
||
|
||
module.exports = { farmingWeight_Embed }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,39 @@ | ||
const { ActionRowBuilder, StringSelectMenuBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); | ||
|
||
const { handleError } = require("../../functions/handle/handleError"); | ||
const { farmingWeight } = require("../../functions/get/getWeight") | ||
const { senitherWeight } = require("../../functions/get/getWeight") | ||
const { farmingWeight_Embed } = require('./embeds/weightEmbed') | ||
const { calculateTotalSenitherWeight } = require('../../functions/constants/senitherWeight') | ||
const { getPlayer } = require("../../functions/get/getPlayer") | ||
module.exports = { | ||
name: 'test', | ||
description: 'bot credits', | ||
options: [ | ||
{ | ||
name: 'message', | ||
name: 'name', | ||
description: 'message to send', | ||
type: 3, | ||
required: true | ||
required: false | ||
}, | ||
|
||
|
||
], | ||
|
||
execute: async (interaction, client) => { | ||
const message = interaction.options.getString('message').replaceAll('\\n', '\n') | ||
const channel = client.channels.cache.get(`1113587258117861378`); | ||
const embed = { | ||
title: `Wtf`, | ||
color: 0xffa600, | ||
description: (`${message}`), | ||
timestamp: new Date().toISOString(), | ||
}; | ||
await channel.send({ embeds: [ embed ] }) | ||
await interaction.reply({content: "Your report has been shared with the developers, do not delete this message.", ephemeral: false}) | ||
execute: async (interaction, client, InteractionCreate) => { | ||
const id = interaction.user.id; | ||
const { uuid2, username, profilename, profileid, playerData, profileData, profile, error } = await getPlayer( | ||
id, | ||
interaction.options.getString("name") | ||
); | ||
// console.log(await calculateTotalSenitherWeight(profile)) | ||
console.log(await senitherWeight(profile)) | ||
await interaction.deferReply(); | ||
|
||
}, | ||
}; | ||
try { | ||
await interaction.editReply({content: "Success."}) | ||
} catch (error) { | ||
const errorEmbed = handleError(error); | ||
await interaction.editReply({ embeds: [errorEmbed] }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
const axios = require('axios'); | ||
require("dotenv").config(); | ||
const apiKey = process.env.KEY; | ||
const fs = require('fs'); | ||
const { addCommas, addNotation } = require("../../contracts/helperFunctions"); | ||
const { calculateTotalSenitherWeight } = require('../../functions/constants/senitherWeight') | ||
|
||
async function farmingWeight(uuid) { | ||
const response = await axios.get(`https://api.elitebot.dev/Weight/${uuid}/selected`); | ||
function sanitizeCropWeight(obj) { | ||
let sanitized = ''; | ||
let crops = []; | ||
for (let crop in obj.cropWeight) { | ||
let weight = obj.cropWeight[crop]; | ||
weight = weight.toFixed(1); | ||
crops.push({ name: crop, weight: weight }); | ||
} | ||
crops.sort((a, b) => b.weight - a.weight); | ||
for (let crop of crops) { | ||
sanitized += `→ ${crop.name}: **${addCommas(crop.weight)}**\n`; | ||
} | ||
return sanitized; | ||
} | ||
function sanitizeBonusWeight(obj) { | ||
let sanitized = ''; | ||
|
||
for (let crop in obj.bonusWeight) { | ||
let weight = obj.bonusWeight[crop]; | ||
weight = weight.toFixed(1); | ||
sanitized += `→ ${crop}: **${addCommas(weight)}**\n`; | ||
} | ||
|
||
return sanitized; | ||
} | ||
return { | ||
total_weight: addCommas(response.data.totalWeight.toFixed(1)), | ||
items: { | ||
crop_weight: sanitizeCropWeight(response.data), | ||
bonus_weight: sanitizeBonusWeight(response.data), | ||
} | ||
} | ||
} | ||
|
||
async function senitherWeight(profile) { | ||
const weight = await calculateTotalSenitherWeight(profile); | ||
function sanitizeData(obj) { | ||
let totalWeight = 0; | ||
let totalOverflow = 0; | ||
let skills = obj.skills; | ||
let slayers = obj.slayer; | ||
let dungeons = obj.dungeons; | ||
// Extract and sum skill, slayer, and dungeon weights and overflows | ||
for (let skill in skills) { | ||
totalWeight += skills[skill].weight; | ||
totalOverflow += skills[skill].weight_overflow; | ||
} | ||
|
||
for (let slayer in slayers) { | ||
totalWeight += slayers[slayer].weight; | ||
totalOverflow += slayers[slayer].weight_overflow; | ||
} | ||
|
||
for (let dungeon in dungeons) { | ||
totalWeight += dungeons[dungeon].weight; | ||
totalOverflow += dungeons[dungeon].weight_overflow; | ||
} | ||
|
||
// Sanitize data | ||
let sanitizedObj = { | ||
totalWeight: totalWeight.toFixed(1), | ||
totalOverflow: totalOverflow.toFixed(1), | ||
skills: formatData(skills), | ||
slayers: formatData(slayers), | ||
dungeons: formatData(dungeons) | ||
}; | ||
return sanitizedObj; | ||
} | ||
function formatData(data) { | ||
let formattedData = ''; | ||
for (let key in data) { | ||
if (data[key].weight !== undefined && data[key].weight_overflow !== undefined) { | ||
let weight = data[key].weight.toFixed(1); | ||
let overflow = data[key].weight_overflow.toFixed(1); | ||
if (overflow !== '0.0') { | ||
formattedData += `→ ${key}: **${addCommas(weight)}** (+${addCommas(overflow)})\n`; | ||
} else { | ||
formattedData += `→ ${key}: **${addCommas(weight)}**\n`; | ||
} | ||
} | ||
} | ||
return formattedData; | ||
} | ||
const data = sanitizeData(weight) | ||
|
||
return data; | ||
} | ||
|
||
module.exports = { farmingWeight, senitherWeight } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,4 +56,4 @@ module.exports = { | |
connect, | ||
getDb, | ||
disconnect | ||
}; | ||
}; |