Answer the question
In order to leave comments, you need to log in
How to update the time every minute?
How can I make the time update every minute so that the rest of the functions work?
I'm probably dumb, but here's a piece of code:
@client.command(pass_context=True)
@commands.has_any_role(admins[0], admins[1], admins[2])
async def clear(ctx, amount=100):
await ctx.channel.purge(limit=amount + 1)
emb = discord.Embed(colour=discord.Color.green())
emb.set_footer(text=f'Администратор {ctx.author.name} удалил {amount} сообщений', icon_url=ctx.author.avatar_url)
await ctx.send(embed=emb)
Answer the question
In order to leave comments, you need to log in
Don't use pass_context. This argument does not exist in the rewrite version of the library.
Regarding the question, using while True
asyncio in code is usually not the best idea, since it almost always blocks the main loop.
Use asyncio tasks: https://docs.python.org/3/library/asyncio-task.html
There is also an extension in discord.py to make it easy to create and process tasks (such as canceling a loop, or a network crash while looping): https://discordpy.readthedocs.io/en/stable/ext/tas...
from discord.ext import tasks, commands
@tasks.loop(seconds=5.0)
async def printer():
print("5 seconds has passed")
printer.start()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question