如何在我的机器人状态下使公会计数器.Discord.py



如何使我的机器人程序显示公会计数器的状态?我是Discord.py的新手,我需要最新版本的帮助。

await bot.change_presence(status=discord.Status.online, activity=discord.Game(f'prefix $ | Serving (...) guilds'))

顺便说一句,我英语不好,如果我的问题不完美的话,很抱歉。

您可能正在寻找bot.guilds,这里有一个关于如何在机器人加入/离开公会时更新活动的示例

@bot.event
async def on_guild_join(guild):
current_guilds = len(bot.guilds)
await bot.change_presence(status=discord.Status.online, activity=discord.Game(f'prefix $ | Serving {current_guilds} guilds'))

@bot.event
async def on_guild_remove(guild):
current_guilds = len(bot.guilds)
await bot.change_presence(status=discord.Status.online, activity=discord.Game(f'prefix $ | Serving {current_guilds} guilds'))

参考:

  • bot.guilds
  • on_guild_join
  • on_guild_move

最新更新