jillo-bot/src/commands/increase.ts

40 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-11-16 11:33:11 +01:00
import { GuildMember, CommandInteraction, SlashCommandBuilder } from 'discord.js';
2023-11-15 11:57:20 +01:00
import { changeCounterInteraction, counterAutocomplete } from '../lib/rpg/counter';
2023-11-16 11:33:11 +01:00
import { Command } from '../types/index';
2023-11-22 14:32:54 +01:00
import { autocomplete } from '../lib/autocomplete';
2022-07-19 21:39:34 +02:00
2023-11-16 11:33:11 +01:00
export default {
2022-07-19 21:39:34 +02:00
data: new SlashCommandBuilder()
.setName('increase')
2023-11-11 00:01:38 +01:00
.setDescription('Increase a counter')
.addStringOption(option =>
option
.setName('type')
.setAutocomplete(true)
.setDescription('The name of the counter')
.setRequired(true)
)
.addIntegerOption((option) =>
2022-07-19 21:39:34 +02:00
option
.setName('amount')
.setRequired(false)
.setDescription('Amount to increase the counter by')
.setMinValue(1)
2023-11-11 00:01:38 +01:00
)
.setDMPermission(false),
2023-11-16 11:33:11 +01:00
execute: async (interaction: CommandInteraction) => {
if (!interaction.isChatInputCommand()) return;
2023-11-11 00:01:38 +01:00
2023-11-16 11:33:11 +01:00
const member = interaction.member! as GuildMember;
2023-11-11 00:01:38 +01:00
const amount = Math.trunc(interaction.options.getInteger('amount') || 1);
const type = interaction.options.getString('type')!;
2022-08-26 18:46:19 +02:00
await interaction.deferReply({ephemeral: true});
2023-11-11 00:01:38 +01:00
changeCounterInteraction(interaction, member, amount, type);
},
2023-11-22 14:32:54 +01:00
autocomplete: autocomplete(counterAutocomplete)
2023-11-16 11:33:11 +01:00
} satisfies Command;