From d0d40286b14e077052c8066e04215a0f07bdfd90 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Thu, 9 Feb 2023 22:00:12 -0500 Subject: [PATCH] make the beginning height optional, defaulting to the trees current heigt --- slash-commands/timetoheight.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/slash-commands/timetoheight.js b/slash-commands/timetoheight.js index f065c86..21c00ec 100644 --- a/slash-commands/timetoheight.js +++ b/slash-commands/timetoheight.js @@ -8,16 +8,21 @@ module.exports = { .setDescription('Calculate how long it would take to reach a given height') .addStringOption(o => o.setName('beginheight') - .setDescription('Begining tree height in feet, numbers ONLY') - .setRequired(true)) + .setDescription('Begining tree height in feet') + .setRequired(false)) .addStringOption(o => o.setName('endheight') - .setDescription('Ending tree height in feet, numbers ONLY') + .setDescription('Ending tree height in feet') .setRequired(true)), async execute(interaction) { await interaction.deferReply({ ephemeral: true }); const beginHeight = interaction.options.getString('beginheight'); const endHeight = interaction.options.getString('endheight'); + if (!beginHeight) { + const getGuildInfoResponse = await dbfn.getGuildInfo(interaction.guildId); + const guildInfo = getGuildInfoResponse.data; + beginHeight = guildInfo.treeHeight; + } 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 => {