Browse Source

Update tasks example to start in `setup_hook`

pull/10109/head
sgtlaggy 2 years ago
committed by dolfies
parent
commit
280351de14
  1. 3
      docs/ext/tasks/index.rst

3
docs/ext/tasks/index.rst

@ -63,6 +63,7 @@ Looping a certain amount of times before exiting:
.. code-block:: python3 .. code-block:: python3
from discord.ext import tasks from discord.ext import tasks
import discord
@tasks.loop(seconds=5.0, count=5) @tasks.loop(seconds=5.0, count=5)
async def slow_count(): async def slow_count():
@ -72,6 +73,8 @@ Looping a certain amount of times before exiting:
async def after_slow_count(): async def after_slow_count():
print('done!') print('done!')
class MyClient(discord.Client):
async def setup_hook(self):
slow_count.start() slow_count.start()
Waiting until the bot is ready before the loop starts: Waiting until the bot is ready before the loop starts:

Loading…
Cancel
Save