Moderation
onlyAdmin
$onlyAdmin
The guard function $onlyAdmin immediately stops the execution of the command if the user who triggered it does not have the Administrator permission on the server.
Syntax
$onlyAdmin[errorMessage]
Parameters
| Parameter | Description |
|---|---|
errorMessage |
Required (may be empty: $onlyAdmin[]). Message returned when the author is not an administrator. |
A bare $onlyAdmin (no brackets) is invalid: it takes exactly one argument.
Behavior
- If the user is an administrator, the command continues normally.
- If the author is not an administrator, the command is immediately interrupted (implicit
$stop) anderrorMessageis output in place of the response. - With an empty
errorMessagenothing is displayed. - The check reads the permissions of the author in the server (
Administrator); the server owner also passes.
Examples
Restricting a command to administrators
$onlyAdmin[Only administrators can use this command.]
$ban[Moderation]
$sendMessage[<@$mentioned[1;no]> was banned.]
Administration Panel
$onlyAdmin[]
$title[⚙️ Admin Panel]
$description[
**Available Commands:**
`!ban`, `!kick`, `!mute`, `!config`
]
$color[#ED4245]
Hybrid Command (Admin or Moderator role)
$if[$isAdmin[$authorID]==false]
$onlyForRoleIDs[123456789012345678;Permission denied.]
$endif
$sendMessage[Moderation action allowed.]
Notes
$onlyAdminonly checks theAdministratorpermission. To check other permissions, use$onlyPerms.- Place this function at the very top of the command, before any other logic.
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.