#Cant loop a task

1 messages · Page 1 of 1 (latest)

dark barn
#

Hey guys!
Can anybody help me how to get a simple example of server running with a task loop?
I tried this example but didnt work:

import disnake

client = disnake.Client()

@client.event
async def on_ready():
    print(f'We have logged in as {client.user}')

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('$hello'):
        await message.channel.send('Hello!')

@tasks.loop(seconds=5.0)
async def docheck():
    print("Running new check.")
    #for summoner in watchedSummoners:
        #if summonerExists(summoner):
            #await gameCheck()
            #await gamerCheck(summoner)

client.run('token')
docheck.start()
fallen bloomBOT
#
Too Many Tags

Please use either the disnake or python tag, but not both. If your question pertains to disnake, please use the disnake tag. If your question is a general python question that does not depend on disnake, please use the python tag.
I've taken a guess based on the contents of your message which your question is actually about.

If you believe this to be in error, please let us know.

upper pike
#

you need to start the task BEFORE the .run()