Discord Python Bot: Changing Status

Viewed 226

I know, that you can change your bots status with:

@bot.event
async def on_ready():
    await bot.change_presence(activity=.....(name="....."))

But is there an easy way to change your status every like 5 seconds maby by using asyncio? Thanks for helping :D

1 Answers

Based on the command of Cool or Fool - SRS here the answer that works pretty well:

@bot.event
async def on_ready():
    bot.loop.create_task(status_task()) # Create loop/task


async def status_task():
    while True:
        await bot.change_presence(activity=discord.Game("XXX"), status=discord.Status.online)
        await asyncio.sleep(ValueInSeconds) # Changes after x seconds
        await bot.change_presence(activity=discord.Game("XXX"), status=discord.Status.online)
        await asyncio.sleep(ValueInSeconds)
  • You can also set watch, listening to or streaming as a status.

For more you can have a look at other posts

Related