Flexes
Flexes

Reputation: 107

How Would I Make This Command Into A Embed?

I'm trying to make a command. And it works like it should but I want to make the command into an embed. I am pretty new to discord.py and coding in general. I know how to make a normal embed but when I try it with this command I keep getting errors. Can someone help? - Thanks :D

Here is my code:

@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}')

Upvotes: 0

Views: 58

Answers (1)

Just for fun
Just for fun

Reputation: 4225

@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)

Upvotes: 1

Related Questions