Skip to content

Instantly share code, notes, and snippets.

@Samarthh2601
Created June 24, 2022 07:15
Show Gist options
  • Save Samarthh2601/a65040969654b9e7ed41bde22bc424af to your computer and use it in GitHub Desktop.
Save Samarthh2601/a65040969654b9e7ed41bde22bc424af to your computer and use it in GitHub Desktop.

All available discord statuses for bots

image

Activities

  1. Listening to ...

  2. Playing ...

  3. Streaming ...

  4. Watching ...

  5. Competing in ...

Where should I change my bots presence and when?


The presence can be changed only when the bot is connected to discord gateway, so it can successfully send a PRESENCE gateway event payload to the gateway in order change the bot's presence. Most libraries allow to set the application's presence within the bot constructor!

How do I get these statuses and activities for my bot?


Discord.py examples

All discord.py status types can be found here. All discord.py activity types can be found here.

Online

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix="<Your prefix>", status=discord.Status.online)

Invisible/offline

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix="<Your prefix>", status=discord.Status.invisible)

Do not disturb

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix="<Your prefix>", status=discord.Status.dnd)

Idle

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix="<Your prefix>", status=discord.Status.idle)

Playing activity

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix="<Your prefix>", status=discord.Status.online, activity=discord.Game(name="with wumpus"))

Streaming activity

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix="<Your prefix>", status=discord.Status.online, activity=discord.Streaming(name="Wumpus Stream", url="the streams url"))

Listening activity

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix="<Your prefix>", status=discord.Status.online, activity=discord.Activity(type=discord.ActivityType.listening, name="The wumpus song"))

Watching activity

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix="<Your prefix>", status=discord.Status.online, activity=discord.Activity(type=discord.ActivityType.watching, name="The wumpus movie"))

Competing activity

import discord
from discord.ext import commands

bot = commands.Bot(command_prefix="<Your prefix>", status=discord.Status.online, activity=discord.Activity(type=discord.ActivityType.competing, name="The wumpus competition"))

You can also change your bots presence after logging.

You can also use the change_presence. method

NOTE: The method should not be used inside of on_ready() as this event can be triggered multiple times after logging in. Resulting in sending multiple of the same PRESENCE gateway event payload to the gateway.

Changing activity after a certain period of time!


A large number of bots having presences that change by themselves after a certain period. In discord.py this can be done using a task loop. You can read more about tasks here.

An example to using changing activity!

import discord
from discord.ext import commands, tasks
import random

bot = commands.Bot(command_prefix="<Your prefix>")

bot.changeable_activites = ("Call of Duty: Warzone", "Fall Guys", "Fortnite", "Call of Duty: Black Ops IV", "Sea of Thieves", "League of Legends", "Valorant")

@tasks.loop(minutes=2)
async def change_activity():
    await bot.wait_until_ready()
    new_activity = random.choice(bot.changeable_activites)
    await bot.change_presence(activity=discord.Game(new_activity))

change_activity.start()

FAQ

Do discord.py forks also follow the same structure for changing presences?

  • Yes, popular discord.py forks such as disnake, nextcord and py-cord also follow the same structure!

What is the minimum duration after which I should change the presence?

  • A gap of 75 seconds is ideal to change the presence of a bot.

Can I change my presence after every 5 seconds?

  • The simple answer is yes. The better answer is no as spamming gateway event payloads to the gateway can result your bot in getting rate-limited from the discord API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment