Moderation
blacklistRolesIDs
$blacklistRolesIDs
The guard function $blacklistRolesIDs blocks the execution of the command for users who have at least one of the listed roles, identified by their ID. It is the ID variant of $blacklistRoles, which compares role names.
Syntax
$blacklistRolesIDs[roleID1;roleID2;...;errorMessage]
Parameters
| Parameter | Type | Description |
|---|---|---|
roleID1;roleID2;... |
Snowflake[] | The IDs of the blacklisted roles. At least one value is required (empty values are ignored). |
errorMessage |
String | Required, always the last argument. Message returned when the guard stops the command; it replaces the output of the script. Leave it empty (; at the end) for a silent stop. |
The function therefore needs at least 2 arguments. With a single argument, the call is rejected (“Invalid argument count”).
Behavior
- Compares the values with the ID of each role of the user (each non-empty value must be a valid Discord ID, otherwise an error “Invalid Discord ID.” is raised). The
@everyonerole (whose ID is the server ID) counts as a role of the user, so blacklisting the server ID blocks everyone. - The match is an OR: a single matching role is enough to block the user.
- If the user has at least one of the roles, the script is stopped and the error message is used as output.
- If the user has none (or all values are empty), the command continues.
Return Value
Returns an empty string when the command continues. When the guard stops the command, the script is stopped and the error message (last argument) is used as its output.
Examples
Block one role
$blacklistRolesIDs[123456789012345678;❌ You are not allowed to use this command.]
$sendMessage[Command executed successfully.]
Multiple roles
$blacklistRolesIDs[111111111111111111;222222222222222222;333333333333333333;❌ You are not allowed to use this command.]
$sendMessage[Processing...]
Silent stop
$blacklistRolesIDs[123456789012345678;]
$sendMessage[Done.]
Notes
- To whitelist roles by ID, use
$onlyForRoleIDs. - To compare role names instead, use
$blacklistRoles.
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.