""" music.py - Prefix commands for music playback. Register: !play - Download and play a song (adds to queue if already playing) !skip - Skip current song, play next !stop - Stop playback, clear queue, leave voice !queue - Show current queue with details !nowplaying - Show currently playing track with remaining time """ from bot.prefix_command_registry import register_prefix_command from bot import voice_manager async def handle_play(message, args): query = " ".join(args) if not query: await message.channel.send("Usage: `!play `") return await voice_manager.resolve_and_enqueue(message, query) async def handle_skip(message, args): guild_id = message.guild.id vc = voice_manager.connections.get(guild_id) if not vc: await message.channel.send("Not playing anything.") return if not vc.is_playing(): await message.channel.send("Not playing anything.") return voice_manager.skip(guild_id) await message.channel.send("Skipped.") async def handle_stop(message, args): guild_id = message.guild.id vc = voice_manager.connections.get(guild_id) if not vc: await message.channel.send("Not playing anything.") return voice_manager.stop(guild_id) await message.channel.send("Stopped and left voice channel.") async def handle_queue(message, args): guild_id = message.guild.id output = voice_manager.get_queue(guild_id) await message.channel.send(output) async def handle_nowplaying(message, args): guild_id = message.guild.id output = voice_manager.get_now_playing(guild_id) await message.channel.send(output) register_prefix_command("play", handle_play) register_prefix_command("skip", handle_skip) register_prefix_command("stop", handle_stop) register_prefix_command("queue", handle_queue) register_prefix_command("nowplaying", handle_nowplaying)