我如何在discord.py中运行1和任何其他bot命令?

问题描述 投票:0回答:1

我想知道是否有一种方法可以在后台运行1个bot命令的内容(具有无限循环),而用户仍然可以使用其他命令。我希望第一个命令在不和谐服务器中的用户仍然可以使用message命令并看到打印的消息时运行。代码如下。谢谢。

@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")
python background command bots discord
1个回答
0
投票

documentation for discord.py链接到example用于此类操作。

© www.soinside.com 2019 - 2024. All rights reserved.