import { CacheType, ChatInputCommandInteraction, SlashCommandBuilder } from 'discord.js'; import { toggleLoop } from '../playback'; import { formatFilePath } from '../util/downloader' const name = "loop" function register() { return new SlashCommandBuilder() .setName(name) .setDescription('loop current song') } async function execute(interaction: ChatInputCommandInteraction) { try { await interaction.deferReply() const audio = toggleLoop() if (audio) { await interaction.editReply(`looped ${formatFilePath(audio.path)}`); } else { await interaction.editReply(`Loop turned off`); } } catch (error) { console.error(error); if (interaction.deferred || interaction.replied) { await interaction.editReply('Coś poszło nie tak :/'); } else { await interaction.reply('Coś poszło nie tak :/'); } } } export default { name, register, execute }