所以,我有我的机器人,我有一个/info用户命令,得到一些用户信息。如果用户有新用户名,我想做一个“如果”。我在/dm命令中这样做了,但它在/info用户命令上不起作用。下面是我的代码:
@info.command(name="user", description="Mostra informações sobre um usuário")
async def _info(self, interaction: discord.Interaction, member: discord.Member):
await interaction.response.defer()
if member.discriminator.endswith("0"):
membro = member.discriminator.strip("#0")
member = membro
info_embed = discord.Embed(color=discord.Color.green())
info_embed.set_thumbnail(url=f"{member.display_avatar})")
info_embed.add_field(name=":placard: Nome", value=f"```{member}```", inline=True)
info_embed.add_field(name=":identification_card: Identidade", value=f"```{member.id}```", inline=True)
info_embed.add_field(name=":link: Menção", value=f"{member.mention}", inline=True)
created = member.created_at.timestamp()
info_embed.add_field(name=":calendar_spiral: Conta Criada", value=f'<t:{int(created)}:F> (<t:{int(created)}:R>)', inline=True)
joined = member.joined_at.timestamp()
info_embed.add_field(name=":date: Entrou em", value=f'<t:{int(joined)}:F> (<t:{int(joined)}:R>)', inline=False)
await interaction.followup.send(embed=info_embed)
有一个错误:discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'discriminator'
顺便说一下,“info”是一个斜杠命令组。
1条答案
按热度按时间sr4lhrrt1#
我修好了