Discord.py获得自定义状态 [英] Discord.py get custom status

查看:57
本文介绍了Discord.py获得自定义状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过discord.py获取Discord用户自定义状态?

我看过discord.py文档.我唯一能找到的就是


参考文献:

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.

解决方案

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:


References:

这篇关于Discord.py获得自定义状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆