Added auto-disconnect feature
This commit is contained in:
12
Music-Bot.py
12
Music-Bot.py
@@ -195,7 +195,7 @@ else:
|
|||||||
finally:
|
finally:
|
||||||
await ctx.send(f"{success}Now playing: `{player.title}`\nRequested by {ctx.author.mention}")
|
await ctx.send(f"{success}Now playing: `{player.title}`\nRequested by {ctx.author.mention}")
|
||||||
while ctx.voice_client.is_playing():
|
while ctx.voice_client.is_playing():
|
||||||
asyncio.sleep(3)
|
await asyncio.sleep(3)
|
||||||
else:
|
else:
|
||||||
await ctx.voice_client.disconnect()
|
await ctx.voice_client.disconnect()
|
||||||
|
|
||||||
@@ -208,9 +208,8 @@ else:
|
|||||||
player, after=lambda e: print(f"Player error: {e}") if e else None
|
player, after=lambda e: print(f"Player error: {e}") if e else None
|
||||||
)
|
)
|
||||||
await ctx.respond(f"{success}Now playing: `{player.title}`\nRequested by {ctx.author.mention}")
|
await ctx.respond(f"{success}Now playing: `{player.title}`\nRequested by {ctx.author.mention}")
|
||||||
print(dir(ctx.voice_client))
|
|
||||||
while ctx.voice_client.is_playing():
|
while ctx.voice_client.is_playing():
|
||||||
asyncio.sleep(3)
|
await asyncio.sleep(3)
|
||||||
else:
|
else:
|
||||||
await ctx.voice_client.disconnect()
|
await ctx.voice_client.disconnect()
|
||||||
|
|
||||||
@@ -256,7 +255,7 @@ else:
|
|||||||
finally:
|
finally:
|
||||||
await ctx.send(f"{success}Now playing: `{player.title}`\nRequested by {ctx.author.mention}")
|
await ctx.send(f"{success}Now playing: `{player.title}`\nRequested by {ctx.author.mention}")
|
||||||
while ctx.voice_client.is_playing():
|
while ctx.voice_client.is_playing():
|
||||||
asyncio.sleep(3)
|
await asyncio.sleep(3)
|
||||||
else:
|
else:
|
||||||
await ctx.voice_client.disconnect()
|
await ctx.voice_client.disconnect()
|
||||||
|
|
||||||
@@ -274,11 +273,6 @@ else:
|
|||||||
ctx.voice_client.stop()
|
ctx.voice_client.stop()
|
||||||
|
|
||||||
|
|
||||||
@bot.event
|
|
||||||
async def on_voice_state_update(ctx: commands.Context):
|
|
||||||
ctx.voice_client.disconnect()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
|
|||||||
Reference in New Issue
Block a user