mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-03 00:25:14 +00:00
Update tasks example to start in setup_hook
This commit is contained in:
@ -63,6 +63,7 @@ Looping a certain amount of times before exiting:
|
||||
.. code-block:: python3
|
||||
|
||||
from discord.ext import tasks
|
||||
import discord
|
||||
|
||||
@tasks.loop(seconds=5.0, count=5)
|
||||
async def slow_count():
|
||||
@ -72,7 +73,9 @@ Looping a certain amount of times before exiting:
|
||||
async def after_slow_count():
|
||||
print('done!')
|
||||
|
||||
slow_count.start()
|
||||
class MyClient(discord.Client):
|
||||
async def setup_hook(self):
|
||||
slow_count.start()
|
||||
|
||||
Waiting until the bot is ready before the loop starts:
|
||||
|
||||
|
Reference in New Issue
Block a user