PEKAH
PEKAH

Reputation: 13

Discord.py: How to make embed role color the highest bot's color?

I want to make a profile command with discord.py and I want the embed message has bot's highest role colour.

My code:

@commands.command()
async def sanj(self, ctx, client, user: discord.Member = None):
    if user == None:
        user = ctx.author
    
    em = Embed(
        title = 'سنج',
        description = f"{user.mention} " + str(randrange(127)) + "% سنج هست",
        colour = client.top_role.colour
    )

    em.add_field(name="پـ.ـن", value="با کامند -help fun بقیه کامندای سنجش رو ببین")

    await ctx.reply(embed=em)

Upvotes: 1

Views: 583

Answers (1)

Ratery
Ratery

Reputation: 2917

Use ctx.guild.me.top_role.colour. You also don't need to add client argument.

@commands.command()
async def sanj(self, ctx, user: discord.Member = None):
    if user == None:
        user = ctx.author
    
    em = Embed(
        title='سنج',
        description=f"{user.mention} " + str(randrange(127)) + "% سنج هست",
        colour=ctx.guild.me.top_role.colour
    )

    em.add_field(name="پـ.ـن", value="با کامند -help fun بقیه کامندای سنجش رو ببین")

    await ctx.reply(embed=em)

Upvotes: 1

Related Questions