有没有办法从 discord.py 获取自定义状态消息?

时间:2021-01-06 19:22:22

标签: discord.py

我有创建用户个人资料卡所需的东西 我想知道如何从discord.py中获取用户指定的消息(文本)。

1 个答案:

答案 0 :(得分:0)

使用 member.activities 获取活动并检查是否有 CustomActivity

@bot.command()
async def status(ctx, m: discord.Member):
    acts = m.activities
    act = [i for i in acts if isinstance(i, discord.CustomActivity)]
    if act:
        act = act[0]
    else:
        return await ctx.send("No Custom Activity")
    text = act.name
    if text:
        await ctx.send(f'Custom Status of {m.name}: **{text}**')
    else:
        return await ctx.send("No text in custom status")