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("skip")
	.setDescription("Skip the current song")
	.setNameLocalizations({ fr: "passer" })
	.setDescriptionLocalizations({ fr: "Passer la musique en cours" })

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.node.skip()
	return interaction.reply(t(interaction.locale, "player.skipped"))
}
