我试图在一条不和谐的嵌入消息的页脚插入一个用户名,上面说是谁请求了命令,我尝试了各种各样的方法,但我不能让它按我想要的方式工作。任何帮助都将不胜感激。我希望它进入price
命令
@client.command(pass_context=True)
async def ping(ctx):
username = ctx.message.author.display_name
channel = ctx.message.channel
t1 = time.perf_counter()
await client.send_typing(channel)
t2 = time.perf_counter()
embed=discord.Embed(title="Pong at {username}".format(username=username), description='It took {}ms.'.format(round((t2-t1)*1000)), color=0xDA70D6)
await client.say(embed=embed)
@client.command(aliases= ['price', 'p'])
async def calc(quantity: int, itemA: str, itemB: str):
#itemAPrice = get_value(itemA)
#itemBPrice = get_value(itemB)
itemAPrice = items[aliases[itemA]]
itemBPrice = items[aliases[itemB]]
if itemAPrice and itemBPrice:
itemQuotient = itemAPrice/itemBPrice
itemBEquivalent = round(quantity * itemQuotient, 2)
embed=discord.Embed(title="Exchange Rate", description='{quantity} {itemA} is equal to {itemBEquivalent} {itemB}'.format(quantity = quantity, itemA = itemA, itemBEquivalent = itemBEquivalent, itemB = itemB), color=0xDA70D6)
await client.say(embed=embed)
elif not itemAPrice:
await client.say('No match found for ' + itemA)
elif not itemBPrice:
await client.say('No match found for ' + itemB)
看起来你不能,只支持文本和图标 https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed.set_footer
将调用上下文传递到命令中,然后使用该上下文获取调用该命令的用户的名称。在那里,您可以使用
ctx.message.author.name
,并将其插入页脚:如果您想提到用户,可以使用
ctx.message.author.mention
相关问题 更多 >
编程相关推荐