From a194d4a4ef4200d607c6a892095764c267fdef34 Mon Sep 17 00:00:00 2001 From: Lukas Blacha Date: Wed, 8 Feb 2023 18:17:31 +0100 Subject: [PATCH] Added auto-disconnect feature --- Music-Bot.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Music-Bot.py b/Music-Bot.py index 6366942..12a6047 100644 --- a/Music-Bot.py +++ b/Music-Bot.py @@ -188,8 +188,7 @@ else: try: player = await YTDLSource.from_url(url, loop=bot.loop) ctx.voice_client.play( - player, after=lambda e: print(f"Player error: {e}") if e else None - ) + player, after=await ctx.voice.disconnect()) except discord.HTTPException as err: raise commands.CommandError(err) finally: @@ -201,8 +200,7 @@ else: async with ctx.typing(): player = await YTDLSource.from_url(url, loop=bot.loop, stream=True) ctx.voice_client.play( - player, after=lambda e: print(f"Player error: {e}") if e else None - ) + player, after=await ctx.voice.disconnect()) await ctx.respond(f"{success}Now playing: `{player.title}`\nRequested by {ctx.author.mention}")