Add cog_unload and before_loop

This commit is contained in:
ekzyis 2021-09-25 16:01:34 +02:00
parent f6ee8ff63f
commit ac6b8783ba
1 changed files with 8 additions and 0 deletions

View File

@ -40,6 +40,10 @@ class Music(commands.Cog):
# pylint: disable=no-member
self._handle_playback.start()
def cog_unload(self):
# pylint: disable=no-member
self._handle_playback.cancel()
@tasks.loop()
async def _handle_playback(self):
while True:
@ -55,6 +59,10 @@ class Music(commands.Cog):
ctx.voice_client.play(audio, after=after)
await ctx.send(f"Now playing: {title}")
@_handle_playback.before_loop
async def before_handle_playback(self):
await self._bot.wait_until_ready()
@commands.command()
async def play(self, ctx, *, query):
async with ctx.typing():