36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { GuildMember, Interaction, SlashCommandBuilder } from 'discord.js';
|
|
import { changeCounterInteraction, counterAutocomplete } from '../lib/counter';
|
|
|
|
module.exports = {
|
|
data: new SlashCommandBuilder()
|
|
.setName('decrease')
|
|
.setDescription('Decrease a counter')
|
|
.addStringOption(option =>
|
|
option
|
|
.setName('type')
|
|
.setAutocomplete(true)
|
|
.setDescription('The name of the counter')
|
|
.setRequired(true)
|
|
)
|
|
.addIntegerOption((option) =>
|
|
option
|
|
.setName('amount')
|
|
.setRequired(false)
|
|
.setDescription('Amount to decrease the counter by')
|
|
.setMinValue(1)
|
|
)
|
|
.setDMPermission(false),
|
|
|
|
execute: async (interaction: Interaction, member: GuildMember) => {
|
|
if (!interaction.isChatInputCommand()) return;
|
|
|
|
const amount = Math.trunc(interaction.options.getInteger('amount') || 1);
|
|
const type = interaction.options.getString('type')!;
|
|
|
|
await interaction.deferReply({ephemeral: true});
|
|
|
|
changeCounterInteraction(interaction, member, -amount, type);
|
|
},
|
|
|
|
autocomplete: counterAutocomplete
|
|
}; |