Discord.py - Count how many servers the bot is in
11,386
Solution 1
Actually you have it!
Just do this
if message.content.startswith('^botservers'):
await message.channel.send("I'm in " + str(len(client.guilds)) + " servers!")
That makes sure you have an str not an int.
Solution 2
It's Not client.servers its client.guilds Here is my example
if message.content.startswith('^botservers'):
await message.channel.send( f"I'm in {len(client.guilds)} servers!")
Author by
Jennifer
Updated on December 09, 2022Comments
-
Jennifer over 1 year
I know it's something like len.client.servers or len(client.servers) but I can't get it to work. I am trying to get it to say "I'm in x servers!" when I say ^botservers. All of the other commands work.
Here's what I have so far:
if message.content.startswith('^botservers'): await client.send_message(message.channel, "I'm in " + len(client.servers) + " servers!")
-
Dan A almost 4 years
guilds
notservers
-
Mary almost 4 years@DanA It is servers. His question was pre 1.0 I'm pretty sure when I answered it. It was later changed to guilds. See: discordpy.readthedocs.io/en/latest/migrating.html
-
Dan A almost 4 yearsahhh Im sorry @Mary