简体   繁体   English

Discord.py 获取自定义状态

[英]Discord.py get custom status

How to get the Discord user custom status through discord.py?如何通过discord.py获取Discord用户自定义状态?

I've seen the discord.py documentation.我看过 discord.py 文档。 And the only thing I could find is Member.status Which returns the status as: online / offline / idle / dnd.我唯一能找到的是Member.status它返回的状态为:在线/离线/空闲/dnd。

But not the new custom status value.但不是新的自定义状态值。 I'm also not searching for the custom presence.我也不是在寻找自定义存在。

What you're after is a CustomActivity .你所追求的是一个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:从您的机器人的应用程序页面: 在此处输入图像描述


References:参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM