jillo-bot/src/commands/decrease.ts

23 lines
779 B
TypeScript
Raw Normal View History

import { Interaction, GuildMember, SlashCommandBuilder } from 'discord.js';
2022-07-19 21:39:34 +02:00
import { changeCounterInteraction } from '../lib/counter';
module.exports = {
data: new SlashCommandBuilder()
.setName('decrease')
.setDescription('Decrease the counter')
.addIntegerOption((option) =>
2022-07-19 21:39:34 +02:00
option
.setName('amount')
.setRequired(false)
.setDescription('Amount to decrease the counter by')
.setMinValue(1)
),
execute: async (interaction: Interaction, member: GuildMember) => {
if (!interaction.isChatInputCommand()) return;
2022-08-26 18:46:19 +02:00
await interaction.deferReply({ephemeral: true});
2022-10-17 20:04:30 +02:00
const amount = Math.trunc(interaction.options.getInteger('amount') || 1);
2023-04-19 21:07:03 +02:00
changeCounterInteraction(interaction, member, -amount, false);
2022-07-19 21:39:34 +02:00
}
};