【问题标题】:How to get the number of servers your bot has joined and display it on the status of the bot如何获取您的机器人加入的服务器数量并将其显示在机器人的状态上
【发布时间】:2022-01-25 18:33:48
【问题描述】:

我想要一些代码,使用 task.loop() 每 30 分钟将状态从 Playing

请帮帮我

【问题讨论】:

  • 嘿,史莱姆!你有任何你尝试过的代码吗? Stackoverflow 通常不是代码编写服务。请包括您尝试过的minimal, reproducible example,以及提供给您的回溯。编码愉快!

标签: python url-rewriting discord.py


【解决方案1】:

您可以创建变量status_state 并使用它来了解您需要设置的状态:

import discord
from discord.ext import tasks

status_state = True

@tasks.loop(minutes=30)
async def change_status():
    global status_state
    new_status = "<help" if status_state else f"{len(bot.guilds)} servers"
    await bot.change_presence(status=discord.Status.online, activity=discord.Game(new_status))
    status_state = not status_state

change_status.start()

【讨论】:

  • 错误:未定义“status_state”
  • @TheSmileyDeveloper_TV 我编辑了我的答案。再看一遍。请
猜你喜欢
  • 2018-12-17
  • 2020-08-24
  • 2020-11-10
  • 2019-05-07
  • 2022-01-27
  • 2022-09-23
  • 2021-04-03
  • 2019-06-15
  • 1970-01-01
相关资源
最近更新 更多