1
1
1 22020-05-29 14:03:26
Python
1 2, 2020-05-29 14:03:26

Discord.py how to display the number of servers on which the bot is located in the status of the bot?

This code does not update the number in the bot status, but how can I do something when adding my bot to the server, the number in the bot status changes?

#подключение
@client.event
async def on_ready():
  guilds = await client.fetch_guilds(limit = None).flatten()
  await client.change_presence(status = discord.Status.idle, activity= discord.Activity(name=f'за {len(guilds)} серверами.', type= discord.ActivityType.watching))
  print( 'Bot connected' )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
1
1 1, 2020-05-29
@Gear_up

The on_ready() event method only works when the bot itself is started.
You just need to replace on_ready() with on_server_join(server).
The server argument is required.
More details here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question