Discord Python: Get a users top role's name and color

Viewed 687

Is there any way I can do this? I haven't found any answer that answers this.

@bot.command()
async def check_rank(ctx)
    if "Administrator" in ctx.author.roles
        color = ctx.author.color
    await ctx.send("Checked rank!")

Something similar? I have this modmail code and I want it to use the users role color and name in the embed.

2 Answers

You can get the top roles from member.roles and the color from member.color

@bot.commmand()
async def check_rank(ctx):
    author = ctx.author # we get the member object
    top_role = author.roles[-1] # first element in roles is `@everyone` and last is top role
    color = author.color

References:

Related