silvanus/slash-commands/watertime.js

26 lines
1.0 KiB
JavaScript
Raw Permalink Normal View History

2023-01-23 06:38:56 +00:00
const { SlashCommandBuilder } = require('discord.js');
const { tree } = require('../modules/functions.js');
const fn = require('../modules/functions.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('watertime')
.setDescription('Calculate the watering time for a given tree height')
.addIntegerOption(o =>
2023-01-23 06:38:56 +00:00
o.setName('height')
.setDescription('Tree height')
.setRequired(true))
.addBooleanOption(o =>
o.setName('private')
.setDescription('Should the response be private? Default: true')
.setRequired(false)),
2023-01-23 06:55:33 +00:00
async execute(interaction) {
const treeHeight = interaction.options.getInteger('height');
const privateOpt = interaction.options.getBoolean('private');
const private = privateOpt != undefined ? privateOpt : true;
await interaction.deferReply( {ephemeral: private });
const waterSeconds = fn.getWaterTime(treeHeight);
const waterTime = fn.parseWaterTime(waterSeconds);
await interaction.editReply(`A tree that is ${treeHeight}ft tall will have a watering time of ${waterTime}.`);
2023-01-23 06:38:56 +00:00
},
};