Added auto-disconnect feature
This commit is contained in:
13
Music-Bot.py
13
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()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user