import type { GuildQueue, Track } from "discord-player"
import type { PlayerMetadata } from "@/types/player"
import { t, getGuildLocale } from "@/utils/i18n"

export const name = "playerSkip"
export async function execute(queue: GuildQueue<PlayerMetadata>, track: Track) {
	// Emitted when the audio player fails to load the stream for a song
	if (!queue.metadata.channel) return

	if ("send" in queue.metadata.channel) {
		const guildLocale = await getGuildLocale(queue.guild.id)
		return queue.metadata.channel.send({ content: t(guildLocale, "player.track_skipped", { title: track.title, author: track.author }) })
	}
}
