import { SlashCommandBuilder, ChatInputCommandInteraction } from 'discord.js';
import { SlashCommand } from '../../utils/types';
import { context } from '../../config/context';

const command: SlashCommand = {
  guildOnly: true,
  data: new SlashCommandBuilder().setName('ticket').setDescription('Erstellt ein persönliches Ticket.'),
  async execute(interaction: ChatInputCommandInteraction) {
    const ticket = await context.tickets.createTicket(interaction);
    if (!ticket) {
      if (!interaction.replied) {
        await interaction.reply({ content: 'Ticket konnte nicht erstellt werden.', ephemeral: true });
      }
      return;
    }
    if (!interaction.replied) {
      await interaction.reply({ content: 'Ticket erstellt! Schau in deinem neuen Kanal nach.', ephemeral: true });
    }
  }
};

export default command;
