How can I make my bot shows guild counter in status? I'm new to Discord.py and I want help with the latest version.
await bot.change_presence(status=discord.Status.online, activity=discord.Game(f'prefix $ | Serving (...) guilds'))
btw I'm not good at English, sorry if my question will not be perfect.
You're probably looking for bot.guilds
, here you have an example on how to update the activity whenever the bot joins/leaves a guild
@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'))
Reference:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.