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

const command: SlashCommand = {
  guildOnly: true,
  data: new SlashCommandBuilder().setName('queue').setDescription('Zeigt die aktuelle Queue.'),
  async execute(interaction: ChatInputCommandInteraction) {
    if (!interaction.guildId) return;
    const info = context.music.getQueueInfo(interaction.guildId);
    if (!info) {
      await interaction.reply({ content: 'Keine Queue vorhanden.', ephemeral: true });
      return;
    }
    const embed = new EmbedBuilder()
      .setTitle('Aktuelle Queue')
      .addFields({ name: 'Jetzt', value: info.nowPlaying ? info.nowPlaying.title : 'Nichts' })
      .setDescription(info.upcoming.map((s, i) => `${i + 1}. ${s.title} — ${s.requester}`).join('\n') || 'Keine weiteren Songs');
    await interaction.reply({ embeds: [embed] });
  }
};

export default command;
