Moderation
takeRoles
$takeRoles
The $takeRoles function removes multiple roles at once from a user on the Discord server. The bot must have the ManageRoles permission.
Syntax
$takeRoles[userID;role1;role2;...]
Parameters
| Parameter | Description |
|---|---|
userID |
The ID of the target user. Required. |
role1;role2;... |
The IDs of the roles to remove (positive numbers), separated by ;. At least one is required. |
Return Value
None (empty string). An error is raised if an ID is invalid.
Examples
Simple Multiple Removal
$takeRoles[$mentioned[1];$roleID[Muted];$roleID[Warned];$roleID[Monitored]]
$sendMessage[All sanctions for <@$mentioned[1]> have been lifted.]
Role Cleanup
$if[$isAdmin[$authorID]==true]
$takeRoles[$mentioned[1];$roleID[VIP];$roleID[Staff];$roleID[Mod]]
$sendMessage[All special roles removed from <@$mentioned[1]>.]
$endif
Conditional Removal
$takeRoles[$authorID;$roleID[Old];$roleID[Inactive]]
$giveRole[$authorID;$roleID[Active]]
$sendMessage[Roles updated!]
Notes
- The bot must have the
ManageRolespermission; each role must be below the bot’s highest role, and@everyoneand managed roles cannot be removed. - The roles are removed one after the other, so an invalid role ID stops the call after the previous roles were removed.
- The role IDs are separated by
;. - To remove a single role,
$takeRoleis simpler. - To completely redefine a user’s roles, use
$setUserRoles.
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.