import { SlashCommandBuilder, MessageFlags } from "discord.js"
import type { ChatInputCommandInteraction } from "discord.js"
import { useQueue } from "discord-player"
import { t } from "@/utils/i18n"

export const data = new SlashCommandBuilder()
	.setName("shuffle")
	.setDescription("Shuffle the queue")
	.setNameLocalizations({ fr: "melanger" })
	.setDescriptionLocalizations({ fr: "Mélange la file d'attente" })

export async function execute(interaction: ChatInputCommandInteraction) {
	const queue = useQueue(interaction.guild?.id ?? "")
	if (!queue) return interaction.followUp({ content: t(interaction.locale, "player.no_queue_search_instead"), flags: MessageFlags.Ephemeral})

	queue.tracks.shuffle()
	return interaction.reply(t(interaction.locale, "player.shuffled"))
}
