Sorry for the long title. I want my bot to tell me how many members that my bot is in a server with in the bot's status. In other words, I want my bot's statues to say Watching [member count] people and [server count] servers
, but I don't know how. Can anyone help?
@client.event
async def on_ready():
print('Potato Cat is ready :D')
await client.change_presence(
activity=discord.Activity(
type=discord.ActivityType.watching,
name=f'{len(client.guilds)} servers and {len(client.members)} people'))
To get the number of servers:
servers = len(client.guilds)
To get the number of members:
members = 0
for guild in client.guilds:
members += guild.member_count - 1 # I've added a '-1' because guild.member_count includes all users and bots including your own bot
So, your on_ready()
event would look like this:
@client.event
async def on_ready():
print('Potato Cat is ready :D')
servers = len(client.guilds)
members = 0
for guild in client.guilds:
members += guild.member_count - 1
await client.change_presence(activity = discord.Activity(
type = discord.ActivityType.watching,
name = f'{servers} servers and {members} members'
))