尝试在discord.py 1.0.1中创建用户状态命令

时间:2019-04-27 21:57:20

标签: python-3.x discord.py-rewrite

#Returns User stats for the server
@client.command()
async def user(ctx, member:discord.User=None):
    if member == None:
        member = ctx.message.author
        pronoun = "Your"
    else:
        pronoun = "Their"
    name = f"{member.name}#{member.discriminator}"
    status = member.Status
    joined = member.joined_at
    role = member.top_role
    await ctx.channel.send(f"{pronoun} name is {name}, {pronoun} status is {status}, They joined at {joined}, {pronoun} rank is {role}")

我正在尝试执行用户统计信息命令,它最初是作为消息事件使用,但我想使其成为命令,以便您可以看到其他用户的统计信息,但是我一直在终端中获取成员对象没有属性状态错误,这是什么?我在这段代码中做错了吗?

1 个答案:

答案 0 :(得分:1)

您的member对象实际上是User类型的,因为您使用的是User转换器。请改用Member转换器。