Add cog_unload and before_loop
This commit is contained in:
parent
f6ee8ff63f
commit
ac6b8783ba
|
@ -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():
|
||||
|
|
Loading…
Reference in New Issue