mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-05 09:26:10 +00:00
Run black on all examples and require it for CI
This commit is contained in:
@ -2,6 +2,7 @@ from discord.ext import tasks
|
||||
|
||||
import discord
|
||||
|
||||
|
||||
class MyClient(discord.Client):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
@ -17,15 +18,16 @@ class MyClient(discord.Client):
|
||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||
print('------')
|
||||
|
||||
@tasks.loop(seconds=60) # task runs every 60 seconds
|
||||
@tasks.loop(seconds=60) # task runs every 60 seconds
|
||||
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
|
||||
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
|
||||
await self.wait_until_ready() # wait until the bot logs in
|
||||
|
||||
|
||||
client = MyClient()
|
||||
client.run('token')
|
||||
|
Reference in New Issue
Block a user