Member-only story
Tutorial | Python | Discord.py
How to Update Discord bot status with Discord.py
Personalizing your bot’s displayed activity for your discord server with Python

Looking at the latest iteration of our Discord bot, it isn’t very exciting. It sits online and watches. Let’s update our bot’s status when it comes online to make it a bit more lively. If you missed the last post on how to use dotenv
to hide your token, see the link below.
The client
object for the bot has a method change_presence
. This method is used to change the bot’s status. There are a couple helper functions that we can use to build statuses.
- Playing: Use
discord.Game()
to display the bot as playing a game. Provide the name of the game to thename
argument - Streaming: Use
discord.Streaming()
to display the bot as streaming with an optionalurl
argument - Listening: Use
discord.Activity()
with thetype
argument set todiscord.ActivityType.listenting
to show the bot as listening to something - Watching: Use
discord.Activity()
with thetype
argument set todiscord.ActivityType.watching
to show the bot as watching something
Examples
Setting the bot’s status when it first comes online will add a bit of polish while it is hanging out in the server. In order to keep things simple, we’ll append the examples to the on_ready
event.
Let’s start with one of the most common statuses seen on Discord, playing a game. This is particularly relevant to the bot I originally set out to build. The bot was going to be in a server dedicated to Sea of Thieves. Naturally, I wanted the bot to be playing Sea of Thieves around the clock.
Adding the following code in the on_ready
function sets the bot’s status to “Playing Sea of Thieves”.
# Startup Information
@client.event
async def on_ready():
await…