Add beginning height option

This commit is contained in:
Skylar Grant 2023-01-26 21:30:52 -05:00
parent a69bca9259
commit 74b65a1978

View File

@ -1,4 +1,5 @@
const { SlashCommandBuilder } = require('discord.js'); const { SlashCommandBuilder } = require('discord.js');
const dbfn = require('../modules/dbfn.js');
const fn = require('../modules/functions.js'); const fn = require('../modules/functions.js');
module.exports = { module.exports = {
@ -6,14 +7,19 @@ module.exports = {
.setName('timetoheight') .setName('timetoheight')
.setDescription('Calculate how long it would take to reach a given height') .setDescription('Calculate how long it would take to reach a given height')
.addStringOption(o => .addStringOption(o =>
o.setName('height') o.setName('beginheight')
.setDescription('Tree height in feet, numbers ONLY') .setDescription('Begining tree height in feet, numbers ONLY')
.setRequired(true))
.addStringOption(o =>
o.setName('endheight')
.setDescription('Ending tree height in feet, numbers ONLY')
.setRequired(true)), .setRequired(true)),
async execute(interaction) { async execute(interaction) {
await interaction.deferReply(); await interaction.deferReply();
const destTreeHeight = interaction.options.getString('height'); const beginHeight = interaction.options.getString('beginheight');
fn.timeToHeight(interaction, destTreeHeight).then(res => { const endHeight = interaction.options.getString('endheight');
interaction.editReply(`It will take you ${res} minutes to reach ${destTreeHeight}ft.`); fn.timeToHeight(beginHeight, endHeight).then(res => {
interaction.editReply(`It will take a tree that is ${beginHeight}ft tall ${res} to reach ${endHeight}ft.`);
}).catch(err => { }).catch(err => {
interaction.editReply("Error: " + err); interaction.editReply("Error: " + err);
console.error(err); console.error(err);