jillo-bot/src/commands/decrease2.ts

22 lines
825 B
TypeScript

import { SlashCommandBuilder } from '@discordjs/builders';
import { CommandInteraction, GuildMember } from 'discord.js';
import { changeCounterInteraction, getCounter } from '../lib/counter';
module.exports = {
data: new SlashCommandBuilder()
.setName('decrease2')
.setDescription('Decrease the cream counter')
.addIntegerOption((option) =>
option
.setName('amount')
.setRequired(false)
.setDescription('Amount to decrease the counter by')
.setMinValue(1)
),
execute: async (interaction: CommandInteraction, member: GuildMember) => {
await interaction.deferReply({ephemeral: true});
const amount = Math.min(Math.trunc(interaction.options.getInteger('amount') || 1), getCounter(true));
changeCounterInteraction(interaction, member, -amount, true);
}
};