[英]Discord py more than one tasks.loop at the same time?
How can I have more than one loop running ate the same time using the same function but using different parameters like:如何使用相同的 function 但使用不同的参数(例如:
@tasks.loop(seconds = 10)
async def loop(name):
Print(name)
loop.start("Jon")
loop.start("Joseph")
Is this how u pass parameters to loops?这是您将参数传递给循环的方式吗?
You need to create a new Loop
object for each loop.您需要为每个循环创建一个新的
Loop
object。 You can do this by using regular function calling repeatedly instead of the decorator:您可以通过使用常规 function 重复调用而不是装饰器来做到这一点:
async def loop(name):
print(name)
names = ["Jon", "Joseph"]
loops = {name: tasks.loop(seconds=10)(name) for name in names}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.