Add water time calucation to /compare

This commit is contained in:
Skylar Grant 2023-01-23 18:14:57 -05:00
parent f632a4e9f0
commit be9f059d96
2 changed files with 8 additions and 5 deletions

View File

@ -150,12 +150,13 @@ const functions = {
let difference = parseFloat(e.height).toFixed(1) - treeHeight;
const absDifference = parseFloat(Math.abs(difference)).toFixed(1);
if (difference > 0) {
replyString += `${absDifference}ft shorter than rank #${e.rank}\n`;
replyString += `#${e.rank} - ${absDifference}ft shorter `;
} else if (difference < 0) {
replyString += `${absDifference}ft taller than rank #${e.rank}\n`;
replyString += `#${e.rank} - ${absDifference}ft taller `;
} else if (difference == 0) {
replyString += `Same height as rank #${e.rank}\n`;
replyString += `#${e.rank} - Same height `;
}
replyString += `[${functions.getWaterTime(e.height)}m]\n`;
});
return 'Here\'s how your tree compares: \n' + replyString;
} else {
@ -236,6 +237,9 @@ const functions = {
} else {
return "Your guild hasn't been set up yet.";
}
},
getWaterTime(size) {
return Math.floor((Math.pow(size * 0.07 + 5, 1.1) / 60));
}
};

View File

@ -13,7 +13,6 @@ module.exports = {
async execute(interaction) {
await interaction.deferReply();
const treeHeight = interaction.options.getString('height');
const waterTime = Math.floor(Math.floor(Math.pow(treeHeight * 0.07 + 5, 1.1)) / 60);
await interaction.editReply(`A tree that is ${treeHeight}ft tall will have a watering time of ${waterTime} minutes.`);
await interaction.editReply(`A tree that is ${treeHeight}ft tall will have a watering time of ${fn.getWaterTime(treeHeight)} minutes.`);
},
};