42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { GuildMember, CommandInteraction, SlashCommandBuilder } from 'discord.js';
|
|
import { changeLinkedCounterInteraction, linkedCounterAutocomplete } from '../lib/rpg/counter';
|
|
import { Command } from '../types/index';
|
|
import { initHealth } from '../lib/rpg/pvp';
|
|
|
|
export default {
|
|
data: new SlashCommandBuilder()
|
|
.setName('put')
|
|
.setDescription('Put an item from your inventory into the 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 of items to put in')
|
|
.setMinValue(1)
|
|
)
|
|
.setDMPermission(false),
|
|
|
|
execute: async (interaction: CommandInteraction) => {
|
|
if (!interaction.isChatInputCommand()) return;
|
|
|
|
const member = interaction.member! as GuildMember;
|
|
|
|
await initHealth(member.id);
|
|
|
|
const amount = Math.trunc(interaction.options.getInteger('amount') || 1);
|
|
const type = interaction.options.getString('type')!;
|
|
|
|
await interaction.deferReply({ephemeral: true});
|
|
|
|
changeLinkedCounterInteraction(interaction, member, amount, type);
|
|
},
|
|
|
|
autocomplete: linkedCounterAutocomplete,
|
|
} satisfies Command; |