Ggblocks20
Ggblocks20

Reputation: 3

Discord.py server status wont work when I use it

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

Answers (1)

Abdulaziz
Abdulaziz

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

Related Questions