我想知道是否有一种方法可以在后台运行 1 个 bot 命令(具有无限循环)的内容,而用户仍然可以使用不同的命令。我希望在不和谐服务器中的用户仍然可以使用消息命令并查看打印消息时运行第一个命令。代码如下。谢谢。
@bot.command() #bot command for printing a random string every 360 seconds
async def initiateauto(ctx):
count=0
await ctx.send(jokerQuotes[random.randint(0,14)])
while True: #timer
print(count)
time.sleep(1)
count=count+1
if count==3600:
await ctx.send(jokerQuotes[random.randint(0,14)])
count=0
@bot.command() #another bot command that prints a message
async def message(ctx):
await ctx.send("Hello")