尝试在 discord.py 1.0.1 中创建用户统计命令
Trying to make a user stats command in discord.py 1.0.1
#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}")
我正在尝试创建一个用户统计命令,它最初是作为消息事件运行的,但我想将其作为一个命令,以便您可以看到另一个用户的统计信息,但我一直在终端中收到成员对象没有属性状态错误,我在这段代码中做错了什么?
您的 member
对象实际上是 User
类型,因为您使用的是 User
转换器。请改用 Member
转换器。
#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}")
我正在尝试创建一个用户统计命令,它最初是作为消息事件运行的,但我想将其作为一个命令,以便您可以看到另一个用户的统计信息,但我一直在终端中收到成员对象没有属性状态错误,我在这段代码中做错了什么?
您的 member
对象实际上是 User
类型,因为您使用的是 User
转换器。请改用 Member
转换器。