close

how to change discord.py bot activity

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about how to change discord.py bot activity in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

how to change discord.py bot activity ?

  1. how to change discord.py bot activity ?

    Reminder for everyone, DO NOT change_presence (or make API calls) in on_ready within your Bot or Client.

  2. change discord.py bot activity

    Reminder for everyone, DO NOT change_presence (or make API calls) in on_ready within your Bot or Client.

Method 1

# Setting `Playing ` status
await bot.change_presence(activity=discord.Game(name="a game"))

# Setting `Streaming ` status
await bot.change_presence(activity=discord.Streaming(name="My Stream", url=my_twitch_url))

# Setting `Listening ` status
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="a song"))

# Setting `Watching ` status
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="a movie"))

Method 2

Reminder for everyone, DO NOT change_presence (or make API calls) in on_ready within your Bot or Client. Discord has a high chance to completely disconnect you during the READY or GUILD_CREATE events (1006 or 1000 close code) and there is nothing you can do to prevent it.

Instead, set the activity and status kwargs in the constructor of these Classes.

Playing -> activity = discord.Game(name="!help")

Streaming -> activity = discord.Streaming(name="!help", url="twitch_url_here")

Listening -> activity = discord.Activity(type=discord.ActivityType.listening, name="!help")

Watching -> activity = discord.Activity(type=discord.ActivityType.watching, name="!help")

bot = commands.Bot(command_prefix="!", activity=activity, status=discord.Status.idle)

Basically: DO NOT do things in on_ready.

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read