Entity Info
lowestRoleWithPerms
$lowestRoleWithPerms
The function $lowestRoleWithPerms[] returns the ID of the lowest role of the server (in the role hierarchy) that possesses one or more specific permissions.
Syntax
$lowestRoleWithPerms[permission1;permission2;...]
Parameters
| Parameter | Description |
|---|---|
permission1;permission2;... |
Required, at least one. Discord permissions, separated by semicolons. All listed permissions must be present on the role. A role with the Administrator permission counts as having all of them. An empty or unknown permission name raises Invalid role permissions. |
Return Value
- Type : Snowflake (numeric string) or empty string
- The ID of the lowest role possessing all requested permissions
- Empty string if no role matches
Behavior
- Scans all the roles of the server (not only the roles of a given user), ordered by the role hierarchy.
@everyoneis part of the scan and is always the last one, so if@everyonehas all the listed permissions (orAdministrator), its ID (the server ID) is returned. - Returns the lowest role that possesses all specified permissions.
- Permission names are in English; case and non-alphanumeric characters are ignored (e.g.
SendMessages), and some aliases (e.g.admin,ban,kick) are accepted.
Examples
Find the lowest role with voice access
$var[voiceRole;$lowestRoleWithPerms[Connect;Speak]]
$if[$var[voiceRole]!=]
$sendMessage[Lowest role granting voice access: $roleName[$var[voiceRole]]]
$endif
Check basic permissions
$var[basicRole;$lowestRoleWithPerms[SendMessages;ReadMessageHistory]]
$if[$var[basicRole]!=]
$sendMessage[The role $roleName[$var[basicRole]] is the lowest role granting message access.]
$endif
Comparison between highest/lowest
$var[highest;$highestRoleWithPerms[ManageMessages]]
$var[lowest;$lowestRoleWithPerms[ManageMessages]]
$title[Moderation Permissions]
$description[
**Highest Role:** $roleName[$var[highest]]
**Lowest Role:** $roleName[$var[lowest]]
]
$color[#5865F2]
Notes
- Useful for determining the minimum level at which a permission is granted.
- If
$highestRoleWithPerms[]and$lowestRoleWithPerms[]return the same ID, only a single role possesses those permissions. - Ideal for permission hierarchy and granular verification systems.
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.