From 0f16af383b4ccdba17b737c00bc39fe0d19c5213 Mon Sep 17 00:00:00 2001 From: Lukas Blacha Date: Wed, 8 Feb 2023 18:47:13 +0100 Subject: [PATCH] Added auto-disconnect feature --- Music-Bot.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Music-Bot.py b/Music-Bot.py index 039fd18..fc21203 100644 --- a/Music-Bot.py +++ b/Music-Bot.py @@ -203,9 +203,6 @@ else: ctx.voice_client.play( player, after=lambda e: print(f"Player error: {e}") if e else None ) - while ctx.voice_client.on_voice_state_update(): - await asyncio.sleep(1) - await ctx.voice_client.disconnect() await ctx.respond(f"{success}Now playing: `{player.title}`\nRequested by {ctx.author.mention}") @@ -264,6 +261,11 @@ else: ctx.voice_client.stop() + @bot.event + async def on_voice_state_update(ctx: commands.Context): + ctx.voice_client.disconnect() + + @bot.event