【问题标题】:Discord Python Bot: Changing StatusDiscord Python Bot:改变状态
【发布时间】:2021-06-29 05:26:02
【问题描述】:

我知道,您可以通过以下方式更改您的机器人状态:

@bot.event
async def on_ready():
    await bot.change_presence(activity=.....(name="....."))

但是有没有一种简单的方法可以通过使用 asyncio 每隔 5 秒更改一次您的状态? 感谢您的帮助:D

【问题讨论】:

标签: python discord bots


【解决方案1】:

根据 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)
  • 您还可以将watchlistening tostreaming 设置为状态。

更多内容可以关注other posts

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-24
    • 2019-08-01
    • 2021-10-29
    • 1970-01-01
    • 2023-03-05
    • 1970-01-01
    • 2017-07-30
    • 2020-12-21
    相关资源
    最近更新 更多