Entity Info
highestRoleWithPerms
$highestRoleWithPerms
The $highestRoleWithPerms function returns the ID of the highest role of the server (in the role hierarchy) that has all the specified permissions.
Syntax
$highestRoleWithPerms[permission1;permission2;...]
Parameters
| Parameter | Description |
|---|---|
permission1;permission2;... |
One or more permissions (at least one is required), separated by semicolons. All listed permissions must be present on the role. |
Return Value
- Type: Snowflake (numeric string) or empty string
- The ID of the highest matching role.
- An empty string if no role has all the requested permissions.
- The error
Invalid role permissions.is raised if a permission name is empty or unknown.
Behavior
- Checks all the roles of the server, from highest to lowest (
@everyonelast); it does not depend on a user. - Returns the first (highest) role that has all the specified permissions.
- A role with the
Administratorpermission satisfies every permission. - Permission names are English, case-insensitive; spaces and symbols are ignored and aliases such as
Admin,BanandKickare accepted.
Examples
Find a moderator role
$var[modRole;$highestRoleWithPerms[ManageMessages]]
$if[$var[modRole]!=]
$sendMessage[Highest role able to manage messages: $roleName[$var[modRole]]]
$else
$sendMessage[No role can manage messages.]
$endif
Check for admin role
$if[$highestRoleWithPerms[Administrator]!=]
$sendMessage[The server has a role with the Administrator permission.]
$endif
Role with ban permissions
$var[banRole;$highestRoleWithPerms[BanMembers]]
$if[$var[banRole]!=]
$title[Ban Role]
$description[
**Role:** $roleName[$var[banRole]]
**ID:** $var[banRole]
]
$color[#ED4245]
$endif
Notes
- Permissions are cumulative: the role must have all the listed permissions.
- If you want a role that has one or another permission, make two separate calls.
- To get the lowest role with these permissions, use
$lowestRoleWithPerms[].
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.