Search code examples
pythondiscordnextcord

How can I get the highest role of a message.author?


i would like to get the name of a highest role in nextcord. Give it a variable for that? If you anything now about this, respond please.

What i have tried:

I have read the docs of nextcord, but i din't found it.

Thank you for you respondig


Solution

  • The description for Member.roles (equivalent to the Message.author's roles property) is pretty clear (emphasis mine):

    A list of Role that the member belongs to. Note that the first element of this list is always the default ‘@everyone’ role.

    These roles are sorted by their position in the role hierarchy."

    Thus, this would make the "highest" role accessible like so:

    message_object.author.roles[-1]