Added auto-disconnect feature

This commit is contained in:
Lukas Blacha
2023-02-08 18:17:31 +01:00
parent f9e5ade444
commit a194d4a4ef

View File

@@ -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}")