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

export const name = "audioTrackAdd"
export async function execute(queue: GuildQueue<PlayerMetadata>, track: Track) {
	// Emitted when the player adds a single song to its queue
	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_added", { title: track.title }) })
	}
}
