Entity Info
highestRole
$highestRole
The $highestRole function returns the ID of the highest role in the server’s role hierarchy. Without argument it looks at all the roles of the server; with a user ID it only looks at the roles of that member.
Syntax
$highestRole[(userID)]
Parameters
| Parameter | Description |
|---|---|
userID |
(Optional) The ID of a member. A value that is not a positive integer raises Invalid user ID. If omitted, all roles of the server are considered, not the roles of the command author. |
Return Value
- Type: Snowflake (numeric string)
- Without argument: the ID of the highest role of the server.
- With a user ID: the ID of the highest role among the roles of that member (
@everyoneis always included in the candidates). - An empty string if there is no candidate role.
Behavior
- Roles are sorted by their Discord position, highest first. At equal positions the role with the smaller (older) ID comes first.
@everyoneis always last. - To get the highest role of the author of the command, pass their ID:
$highestRole[$authorID].
Examples
Display the highest role
$title[Profile of $userName]
$author[$userName;$userAvatar[$authorID]]
$description[
**Highest Role:** <@&$highestRole[$authorID]>
**Role Name:** $roleName[$highestRole[$authorID]]
]
$color[#$getRoleColor[$highestRole[$authorID]]]
Check hierarchy
$if[$highestRole[$authorID]==123456789012345678]
$sendMessage[You are a staff member!]
$else
$sendMessage[Highest role: $roleName[$highestRole[$authorID]]]
$endif
Comparison of roles
$var[modRole;123456789012345678]
$if[$rolePosition[$highestRole[$authorID]]<=$rolePosition[$var[modRole]]]
$sendMessage[You have a role greater than or equal to Moderator.]
$endif
Notes
$rolePosition[roleID]returns the rank in the same ordering, where1is the highest role: a smaller number means a higher role.- The
@everyonerole is always last in the ordering. - For the lowest role, use
$lowestRole. - Use
$roleName[roleID]to get the name of a role.
Try it
Paste an example into the playground to preview its message (functions that act on Discord are not run), or build the same thing with blocks.