From 8ff36532cc934e401a802d3e24530e8acf544c12 Mon Sep 17 00:00:00 2001 From: Lukas Blacha Date: Wed, 8 Feb 2023 18:38:21 +0100 Subject: [PATCH] Added auto-disconnect feature --- Music-Bot.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Music-Bot.py b/Music-Bot.py index f75a2e1..1ab8668 100644 --- a/Music-Bot.py +++ b/Music-Bot.py @@ -203,7 +203,9 @@ else: ctx.voice_client.play( player, after=lambda e: print(f"Player error: {e}") if e else None ) - + while ctx.is_playing(): + await asyncio.sleep(1) + await ctx.disconnect() await ctx.respond(f"{success}Now playing: `{player.title}`\nRequested by {ctx.author.mention}") @@ -261,15 +263,6 @@ else: elif ctx.voice_client.is_playing(): ctx.voice_client.stop() - @bot.event - async def on_voice_state_update(ctx: commands.Context): - while True: - await asyncio.sleep(1) - if ctx.voice_client.is_playing() and not ctx.voice_client.is_paused(): - pass - else: - await ctx.voice_client.disconnect() -