Reputation: 3
I am making a discord bot’s status change, and it seems to work but when it shows up it says watching 0 servers. I don’t know what’s wrong. Here is my code
import discord
client = discord.Client()
activity_string = 'on {} servers.'.format(len(client.guilds))
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$hello'):
await message.channel.send('Hello!')
# Startup Information
# Startup Information
@client.event
async def on_ready():
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=activity_string))
client.run(“my token”)
Upvotes: 0
Views: 113
Reputation: 3426
You should use it like this. With the name inside on_ready()
@bot.event
async def on_ready():
print("Logged in as")
print(bot.user.name)
print("------")
activity = discord.Activity(name="$help", type=discord.ActivityType.listening)
await bot.change_presence(activity=activity)
Upvotes: 1