import { MessageFlags } from "discord.js"
import type { ButtonInteraction } from "discord.js"
import { useHistory } from "discord-player"
import { t } from "@/utils/i18n"

export const id = "player_previous"
export async function execute(interaction: ButtonInteraction) {
	const history = useHistory(interaction.guild?.id ?? "")
	if (!history) return

	await history.previous()
	return interaction.followUp({ content: t(interaction.locale, "player.previous_played"), flags: MessageFlags.Ephemeral })
}
