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

const command: SlashCommand = {
  guildOnly: true,
  data: new SlashCommandBuilder()
    .setName('loop')
    .setDescription('Loop-Modus setzen (off/song/queue).')
    .addStringOption((opt) =>
      opt
        .setName('mode')
        .setDescription('Loop Modus')
        .addChoices(
          { name: 'aus', value: 'off' },
          { name: 'song', value: 'song' },
          { name: 'queue', value: 'queue' }
        )
        .setRequired(true)
    ),
  async execute(interaction: ChatInputCommandInteraction) {
    if (!interaction.guildId) return;
    const mode = interaction.options.getString('mode', true) as LoopMode;
    context.music.setLoop(interaction.guildId, mode);
    await interaction.reply({ content: `Loop-Modus: ${mode}` });
  }
};

export default command;
