Moderation
takeRole
$takeRole
The $takeRole function removes a role from a user on the Discord server. The bot must have the ManageRoles permission.
Syntax
$takeRole[userID;roleID]
$takeRole[roleID]
Parameters
| Parameter | Description |
|---|---|
userID |
Optional - The ID of the target user. If only one argument is given, it is read as the role ID and the role is removed from the users mentioned in the message; an error is raised if there is no mention (the author is never used as a fallback). |
roleID |
The ID of the role to remove (a positive number). Required. |
Return Value
None (empty string). An error is raised if the user ID or role ID is invalid.
Examples
Simple Removal
$takeRole[$mentioned[1];$roleID[Muted]]
$sendMessage[🔊 <@$mentioned[1]> is no longer muted!]
Removal After Verification
$if[$checkContains[$userRoles[$mentioned[1]];$roleID[Muted]]==true]
$takeRole[$mentioned[1];$roleID[Muted]]
$sendMessage[Muted role removed.]
$else
$sendMessage[This user does not have the Muted role.]
$endif
Removal Command with Confirmation
$takeRole[$mentioned[1];$roleID[$message[2]]]
$sendMessage[✅ Role removed from <@$mentioned[1]>.]
Notes
- The bot must have the
ManageRolespermission. - The bot must have
Manage Roles; the role must be below the bot’s highest role, and@everyoneand managed roles (bot, integration, booster) cannot be removed. - To remove multiple roles, use
$takeRoles.
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.