diff --git a/examples/background_task.py b/examples/background_task.py index 77ca885a2..a8a7f99c3 100644 --- a/examples/background_task.py +++ b/examples/background_task.py @@ -9,6 +9,7 @@ class MyClient(discord.Client): # an attribute we can access from our task self.counter = 0 + async def setup_hook(self) -> None: # start the task to run in the background self.my_background_task.start() diff --git a/examples/background_task_asyncio.py b/examples/background_task_asyncio.py index be445e91d..860916bb0 100644 --- a/examples/background_task_asyncio.py +++ b/examples/background_task_asyncio.py @@ -5,6 +5,7 @@ class MyClient(discord.Client): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) + async def setup_hook(self) -> None: # create the background task and run it in the background self.bg_task = self.loop.create_task(self.my_background_task())