39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { GuildMember, CommandInteraction, SlashCommandBuilder } from 'discord.js';
|
|
import { changeCounterInteraction, counterAutocomplete } from '../lib/rpg/counter';
|
|
import { Command } from '../types/index';
|
|
|
|
export default {
|
|
data: new SlashCommandBuilder()
|
|
.setName('increase')
|
|
.setDescription('Increase 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 increase the counter by')
|
|
.setMinValue(1)
|
|
)
|
|
.setDMPermission(false),
|
|
|
|
execute: async (interaction: CommandInteraction) => {
|
|
if (!interaction.isChatInputCommand()) return;
|
|
|
|
const member = interaction.member! as GuildMember;
|
|
|
|
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,
|
|
} satisfies Command; |