aboutsummaryrefslogtreecommitdiff
path: root/examples/background_task.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2021-03-30 20:28:41 -0400
committerRapptz <[email protected]>2021-03-30 20:28:41 -0400
commite359aeb122175cfc573e61638f06dd30eb29a7a8 (patch)
treebdf2cd81b19e38c42302413155238650d662e4ee /examples/background_task.py
parentUpdate background_task example to use ext.tasks (diff)
downloaddiscord.py-e359aeb122175cfc573e61638f06dd30eb29a7a8.tar.xz
discord.py-e359aeb122175cfc573e61638f06dd30eb29a7a8.zip
Fix background_task example to actually work
Diffstat (limited to 'examples/background_task.py')
-rw-r--r--examples/background_task.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/examples/background_task.py b/examples/background_task.py
index f2da6750..5c07ad1a 100644
--- a/examples/background_task.py
+++ b/examples/background_task.py
@@ -18,16 +18,15 @@ class MyClient(discord.Client):
print(self.user.id)
print('------')
- @my_background_task.before_loop
- async def before_my_task(self):
- await self.wait_until_ready() # wait until the bot logs in
-
@tasks.loop(seconds=60) # task runs every 60 seconds
async def my_background_task(self):
channel = self.get_channel(1234567) # channel ID goes here
self.counter += 1
- await channel.send(counter)
+ await channel.send(self.counter)
+ @my_background_task.before_loop
+ async def before_my_task(self):
+ await self.wait_until_ready() # wait until the bot logs in
client = MyClient()
client.run('token')