T
T
TanderOFF2021-04-18 04:33:55
Python
TanderOFF, 2021-04-18 04:33:55

How to set the color of Embed with a command what would it accept in hex?

Hello . I wanted to change the color of the embed using the command !emcolor 378cdc
I tried to use string addition: And apply the "col" variable already to But it doesn't work . How can I fix it? Here is the complete code:
col = str('0x') + str(test)
color=col

@client.command(aliases=['emcolor'])
async def colorsss(ctx, test: str = None):

    col = str('0x') + str(test)
    print(f'{col}') 

    if test is None:
        emb = discord.Embed(description='Мой префикс: `ae` или `!` \nКанал где описаны все мои команды <#769700056403804180>\nМоя статистика: `!bot`', color=0x2F3136)
        emb.set_footer(text=f'{ctx.guild.name} | ID: {ctx.guild.id}', icon_url=f'{ctx.guild.icon_url}').set_thumbnail(url='https://images-ext-2.discordapp.net/external/DAHVXGlumncvzfwTIRcrZg_Cp2OwDHQiDIpRfDcDXh0/%3Fsize%3D512/https/cdn.discordapp.com/avatars/704649259810816091/3007675da244370c2bd7e7fa4f198969.png')
        await ctx.send(embed=emb)
    else:
        emb1 = discord.Embed(description='Мой префикс: `ae` или `!` \nКанал где описаны все мои команды <#769700056403804180>\nМоя статистика: `!bot`', color=col)
        emb1.set_footer(text=f'{ctx.guild.name} | ID: {ctx.guild.id}', icon_url=f'{ctx.guild.icon_url}').set_thumbnail(url='https://images-ext-2.discordapp.net/external/DAHVXGlumncvzfwTIRcrZg_Cp2OwDHQiDIpRfDcDXh0/%3Fsize%3D512/https/cdn.discordapp.com/avatars/704649259810816091/3007675da244370c2bd7e7fa4f198969.png')
        await ctx.send(embed=emb1)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Nevzorov, 2021-04-19
@TanderOFF

Use converters:
https://discordpy.readthedocs.io/en/stable/ext/com...
https://discordpy.readthedocs.io/en/stable/ext/com...

@bot.command()
async def emcolor(ctx, color: discord.Color):
    """Set embed color"""
    await ctx.send(embed=discord.Embed(title="a",color=color))

A
Alexander, 2021-04-18
@Alexandre888

most likely, you specified embendinstead of embed:

- message.channel.send(embend=. . .)
+ message.channel.send(embed=. . .)

V
Vladislav Mukhin, 2021-04-18
@SladkayaDoza

You can change Hex to Dex

k = color.replace('#','')
col = int(k , 16)

And then already use it
emb = discord.Embed(description = text, color=col)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question