mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 20:28:38 +00:00
Fix background_task example to actually work
This commit is contained in:
parent
5ed47cacc7
commit
e359aeb122
@ -18,16 +18,15 @@ class MyClient(discord.Client):
|
|||||||
print(self.user.id)
|
print(self.user.id)
|
||||||
print('------')
|
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
|
@tasks.loop(seconds=60) # task runs every 60 seconds
|
||||||
async def my_background_task(self):
|
async def my_background_task(self):
|
||||||
channel = self.get_channel(1234567) # channel ID goes here
|
channel = self.get_channel(1234567) # channel ID goes here
|
||||||
self.counter += 1
|
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 = MyClient()
|
||||||
client.run('token')
|
client.run('token')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user