我在使用 user-finder 命令时遇到了一些问题。 我的错误可能比显示的要多,但以下是我所知道的:
embed.add_field(name='User ID', value=text=str(user.id))
^
SyntaxError: invalid syntax
Code :
@Client.command()
async def ui(ctx, *, user: discord.Member = None):
if user is None:
user = ctx.author
date_format = "%a, %d %b %Y %I:%M %p"
embed = discord.Embed(color=0xA9A9A9, description='.ui <ID>')
embed.set_author(name=str(user), icon_url=user.avatar_url)
embed.set_thumbnail(url=user.avatar_url)
if user.bot:
embed.add_field(name="Bot? ", value='Yes')
else:
embed.add_field(name="Bot?", value='No')
embed.add_field(name="Regiestered", value=user.created_at.strftime(date_format))
embed.add_field(name='User ID', value=text=str(user.id))
return await ctx.send(embed=embed)
答案 0 :(得分:1)
首先是client.command()
,而不是Client.command()
。
正如 12944qwerty 在评论中所述,没有这样的 value=text=str(...)
,因为这会导致 SyntaxError
。
看看“新”代码:
@client.command() # Client to client
async def ui(ctx, *, user: discord.Member = None):
if user is None:
user = ctx.author
date_format = "%a, %d %b %Y %I:%M %p"
embed = discord.Embed(color=0xA9A9A9, description='.ui <ID>')
embed.set_author(name=str(user), icon_url=user.avatar_url)
embed.set_thumbnail(url=user.avatar_url)
if user.bot:
embed.add_field(name="Bot? ", value='Yes')
else:
embed.add_field(name="Bot?", value='No')
embed.add_field(name="Regiestered", value=user.created_at.strftime(date_format))
embed.add_field(name='User ID', value=f"{user.id}") # Used f-strings
return await ctx.send(embed=embed)