【发布时间】:2021-06-29 05:26:02
【问题描述】:
我知道,您可以通过以下方式更改您的机器人状态:
@bot.event
async def on_ready():
await bot.change_presence(activity=.....(name="....."))
但是有没有一种简单的方法可以通过使用 asyncio 每隔 5 秒更改一次您的状态? 感谢您的帮助:D
【问题讨论】:
-
我看到了,但对我没有帮助
我知道,您可以通过以下方式更改您的机器人状态:
@bot.event
async def on_ready():
await bot.change_presence(activity=.....(name="....."))
但是有没有一种简单的方法可以通过使用 asyncio 每隔 5 秒更改一次您的状态? 感谢您的帮助:D
【问题讨论】:
根据 Cool or Fool - SRS 的命令,这里的答案非常有效:
@bot.event
async def on_ready():
bot.loop.create_task(status_task()) # Create loop/task
async def status_task():
while True:
await bot.change_presence(activity=discord.Game("XXX"), status=discord.Status.online)
await asyncio.sleep(ValueInSeconds) # Changes after x seconds
await bot.change_presence(activity=discord.Game("XXX"), status=discord.Status.online)
await asyncio.sleep(ValueInSeconds)
watch、listening to 或streaming 设置为状态。更多内容可以关注other posts
【讨论】: