make the beginning height optional, defaulting to the trees current heigt
This commit is contained in:
parent
0b6161f0e0
commit
d0d40286b1
@ -8,16 +8,21 @@ module.exports = {
|
|||||||
.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('beginheight')
|
o.setName('beginheight')
|
||||||
.setDescription('Begining tree height in feet, numbers ONLY')
|
.setDescription('Begining tree height in feet')
|
||||||
.setRequired(true))
|
.setRequired(false))
|
||||||
.addStringOption(o =>
|
.addStringOption(o =>
|
||||||
o.setName('endheight')
|
o.setName('endheight')
|
||||||
.setDescription('Ending tree height in feet, numbers ONLY')
|
.setDescription('Ending tree height in feet')
|
||||||
.setRequired(true)),
|
.setRequired(true)),
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
await interaction.deferReply({ ephemeral: true });
|
await interaction.deferReply({ ephemeral: true });
|
||||||
const beginHeight = interaction.options.getString('beginheight');
|
const beginHeight = interaction.options.getString('beginheight');
|
||||||
const endHeight = interaction.options.getString('endheight');
|
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 => {
|
fn.timeToHeight(beginHeight, endHeight).then(res => {
|
||||||
interaction.editReply(`It will take a tree that is ${beginHeight}ft tall ${res} to reach ${endHeight}ft.`);
|
interaction.editReply(`It will take a tree that is ${beginHeight}ft tall ${res} to reach ${endHeight}ft.`);
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
Loading…
Reference in New Issue
Block a user