Reputation: 155
How to get the Discord user custom status through discord.py?
I've seen the discord.py documentation. And the only thing I could find is Member.status
Which returns the status as: online / offline / idle / dnd.
But not the new custom status value. I'm also not searching for the custom presence.
Upvotes: 1
Views: 4318
Reputation: 6944
What you're after is a CustomActivity
.
As explained by in the docs, a user can have multiple activities, but try this out for size:
@bot.command()
async def mycustomstatus(ctx):
for s in ctx.author.activities:
if isinstance(s, discord.CustomActivity):
await ctx.send(s)
On a slightly related note: Please bear in mind that bots cannot set custom activities as of the time of writing this answer; only read them.
EDIT:
If you can't get a member's activity, make sure you have enabled privileged intents:
import discord
intents = discord.Intents().all()
bot = commands.Bot(command_prefix=..., intents=intents)
And from your bot's application page:
Member.activities
discord.CustomActivity
isinstance()
- Python builtinUpvotes: 5