Moderation
hasPerms
$hasPerms
The function $hasPerms is an inline permission check. Unlike guards ($onlyPerms, $onlyBotPerms), it does not interrupt the command but returns "true" or "false", allowing fine-grained conditional management.
Syntax
$hasPerms[userID;permission1;permission2;...]
Parameters
| Parameter | Type | Description |
|---|---|---|
userID |
Snowflake | The ID of the user whose permissions to check. |
permission1;permission2;... |
String[] | List of permissions to verify (at least one is required). All permissions must be present. |
Return Value
- Type: String
"true"or"false" "true": the user has all listed permissions"false": at least one permission is missing- An error is raised if the user ID is invalid, if a permission name is empty or unknown, or if the member cannot be read.
Behavior
- Checks the permissions of the user on the server (from their roles; channel overwrites are not applied).
- The check is of type AND: all listed permissions are required.
- The
Administratorpermission (and server ownership) implicitly satisfies all others. - A member currently timed out only keeps the view-channel and read-history permissions.
- Permission names are case-insensitive and ignore spaces and symbols; aliases such as
Admin,BanandKickare accepted. - Does not interrupt the command (unlike
$onlyPerms).
Examples
Simple Conditional Check
$if[$hasPerms[$authorID;BanMembers]==true]
$banID[$noMentionMessage;$mentioned[1]]
$sendMessage[Member banned.]
$else
$sendMessage[❌ You do not have permission to ban.]
$endif
Multi-Permission Check
$if[$hasPerms[$authorID;ManageMessages;ManageChannels]==true]
$clear[$message[1]]
$sendMessage[$message[1] messages deleted.]
$else
$sendMessage[❌ Insufficient permissions.]
$endif
Check Bot Permissions
$if[$hasPerms[$botID;KickMembers]==false]
$sendMessage[⚠️ I do not have permission to kick. Please check my permissions.]
$stop
$endif
$kick[$mentioned[1]]
Conditional Log
$if[$hasPerms[$authorID;Administrator]==true]
$log[Admin action: $userName used the command.]
$endif
Notes
$hasPermsis an inline function: it does not block the command. Use it with$ifto create conditional behaviors.- For the bot, use
$botIDas theuserID. - Permission names are usually written in PascalCase (
BanMembers,KickMembers,ManageMessages, etc.); case does not matter. - For a check with automatic interruption, use
$onlyPerms(user) or$onlyBotPerms(bot). $checkUserPermsis an alias of$hasPerms.
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.