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():