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

export const id = "player_volume_down"
export async function execute(interaction: ButtonInteraction) {
	const queue = useQueue(interaction.guild?.id ?? "")
	if (!queue) return

	const volume = queue.node.volume - 10
	queue.node.setVolume(volume)
	return interaction.followUp({ content: t(interaction.locale, "player.volume_changed_down", { volume: volume.toString() }), flags: MessageFlags.Ephemeral })
}
