0

I'm working on a discord bot, and I need something to loop every 10 seconds. I've tried following some tutorials, but it doesn't seem to be working. Here's my code:

import discord
from discord.ext import tasks, commands
import asyncio
import passwords


client = commands.Bot(command_prefix = '.');



@tasks.loop(seconds=10)
async def name_of_function():
    print("looped")


client.run(passwords.token)

The token and such are working fine, I just have them in another file. When I run this, nothing happens. It never prints looped, and I've been letting it run for up to 10 minutes. What am I doing wrong, and why won't this loop?

1 Answer 1

1

You need to actually start the loop as well, using name_of_function.start(). Make sure to put this before client.run(), as otherwise it will never be called either.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.