diff --git a/cogs/music.py b/cogs/music.py index ade99ec..1f56ef2 100644 --- a/cogs/music.py +++ b/cogs/music.py @@ -1128,6 +1128,52 @@ async def autoplay(self, interaction: discord.Interaction) -> None: ), ) + @app_commands.command( + name="loop", + description="Cambia el modo de repetición: off / track / queue", + ) + @app_commands.describe(mode="off = sin repetición, track = repetir canción, queue = repetir cola") + @app_commands.choices(mode=[ + app_commands.Choice(name="Off — reproducción normal", value="off"), + app_commands.Choice(name="Track — repite la canción actual", value="track"), + app_commands.Choice(name="Queue — repite toda la cola", value="queue"), + ]) + async def loop(self, interaction: discord.Interaction, mode: str): + """Cambiar modo de loop: off / track / queue""" + try: + player, error_message = self._require_control_player(interaction) + if player is None: + return await self._send_error(interaction, error_message) + + loop_map = { + "off": (lavalink.DefaultPlayer.LOOP_NONE, "Off", BOT_PRIMARY), + "track": (lavalink.DefaultPlayer.LOOP_SINGLE, "Track", BOT_SUCCESS), + "queue": (lavalink.DefaultPlayer.LOOP_QUEUE, "Queue", BOT_SUCCESS), + } + loop_val, label, color = loop_map[mode] + + player.set_loop(loop_val) + print(f"[LOOP] guild={interaction.guild.id} modo={label}") + + descriptions = { + "off": "Reproducción normal — la cola avanza secuencialmente.", + "track": "🔂 Repitiendo la canción actual infinitamente.", + "queue": "🔁 Cuando la cola termine, vuelve a empezar desde el principio.", + } + + await self._send_embed( + interaction, + self._build_embed( + interaction, + f"Loop: {label}", + descriptions[mode], + color=color, + ), + ) + except Exception as e: + print(f"[LOOP] ✗ Error: {e}") + await self._send_error(interaction, f"Error: {e}") + @app_commands.command( name="play", description="Reproduce una canción (nombre o URL)" ) @@ -1456,9 +1502,11 @@ async def nowplaying(self, interaction: discord.Interaction): embed.add_field( name="Autor", value=track.author or "Desconocido", inline=True ) + loop_label = {0: "", 1: " 🔂 Loop track", 2: " 🔁 Loop queue"}.get(player.loop, "") + status = ("En vivo" if track.is_stream else "En reproducción") + loop_label embed.add_field( name="Estado", - value="En vivo" if track.is_stream else "En reproducción", + value=status, inline=True, ) embed.add_field(name="Duración", value=duration_label, inline=True)