From ac6b8783ba33483248b56a819bc4c7effebb1662 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Sat, 25 Sep 2021 16:01:34 +0200 Subject: [PATCH] Add cog_unload and before_loop --- src/bot.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/bot.py b/src/bot.py index c43c21d..c5c4f98 100644 --- a/src/bot.py +++ b/src/bot.py @@ -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():