我如何将此命令嵌入到嵌入中?

时间:2020-08-10 16:58:01

标签: python discord.py

我正在尝试发出命令。它的工作方式应该像它应该的那样,但是我想将命令嵌入到其中。一般来说,我对discord.py和编码尚不陌生。我知道如何制作普通的嵌入,但是当我使用此命令尝试嵌入时,会不断出现错误。有人可以帮忙吗? -谢谢:D

这是我的代码:

@client.command()
async def cid(ctx, *, content = None):
    if content is None:
        await ctx.send(f'No skin was given, try: lamo')
    else:
        try:
            cosmetic = await BenBotAsync.get_cosmetic(
                lang="en",
                searchLang="en",
                matchMethod="contains",
                name=content,
                backendType="AthenaCharacter"
            )
            await ctx.send(f'{cosmetic.name} is: {cosmetic.id}')
        except BenBotAsync.exceptions.NotFound:
            await ctx.send(f'Could not find a skin named: {content}')

1 个答案:

答案 0 :(得分:1)

@client.command()
async def cid(ctx, *, content = None):
    if content is None:
        embed = discord.Embed(title="Error", description="No skin name was passed", colour=discord.Colour.red())
        await ctx.send(embed=embed)
    else:
        try:
            cosmetic = await BenBotAsync.get_cosmetic(
                lang="en",
                searchLang="en",
                matchMethod="contains",
                name=content,
                backendType="AthenaCharacter"
            )
            e = discord.Embed(title="Skin Details", description=f"**{cosmetic.name}** is: **{cosmetic.id}**", colour=discord.Colour.green())
            await ctx.send(embed=e)
        except BenBotAsync.exceptions.NotFound:
            e = discord.Embed(title="Error", description=f"Could not find a skin named: **{content}**", colour=discord.Colour.red())
            await ctx.send(embed=e)