You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将Discord机器人的Streaming状态修改为Idle并设置观看所在服务器

修改方法

你只需要调整on_ready事件末尾的bot.change_presence调用参数即可,两个核心改动点如下:

  • 添加status=discord.Status.idle参数,将机器人在线状态设置为Idle
  • 把原来的discord.Streaming活动类型替换为discord.Activity,指定活动类型为watching,内容改为服务器数量相关展示文本

修改后的完整代码如下:

@bot.event
async def on_ready():
  print(f'Loged in as {bot.user}\n')
  cmds = filter(lambda e: e.endswith(".py"), os.listdir("commands"))
  print(f"Loading Commands")
  for cmd in cmds:
    bot.load_extension(f"commands.{cmd[:-3]}")
    print(f"Loaded {cmd}")
  await bot.change_presence(
    status=discord.Status.idle,
    activity=discord.Activity(
      type=discord.ActivityType.watching,
      name=f"{len(bot.guilds)} 个服务器"
    )
  )

如果你需要保留原来的帮助命令提示,也可以把name参数改为f"{len(bot.guilds)} 个服务器 | {prefix}help",显示效果和你原来的Streaming状态的文本结构一致。

内容的提问来源于stack exchange,提问作者Galaxy_Shots

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.11 11:36:03