我知道,您可以通过以下方式更改您的机器人状态:
@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)
- 您还可以将
观看
、收听
或流媒体
设置为状态。
更多内容可以看other posts
关于python - Discord Python 机器人 : Changing Status,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66917638/