BlocksDiscord
Remove User Role
Automatically remove one or multiple roles from a Discord user.
The Remove User Role block allows you to take away specific roles from a user. This is useful for revoking access when a subscription ends, removing "New Member" tags after onboarding, or handling moderation tasks.
Core Concept
If assigning roles is like giving someone a "key", this block is like "taking the key back". Your Bot can instantly remove specific permissions or badges from a user's profile.
Hierarchy Constraints
Just like adding roles, your Bot can only remove roles that are lower than its own position in the server's role list.
Configuration
| Field | Required | Description |
|---|---|---|
| Bot Token | ✅ | The secret variable containing your Discord Bot Token. |
| Guild ID | ✅ | The unique ID of the Discord Server. |
| User ID | ✅ | The unique ID of the User to remove roles from. |
| Role IDs | ✅ | A list of one or more Role IDs to remove. |
| Audit Log Reason | — | An optional message explaining why the roles were removed. |
| Output Variable | ✅ | Stores the result of the operation. |
Output Data
Upon success, the output variable will contain:
{
"message": "Roles removed successfully",
"role_ids": ["112233445566778899"],
"user_id": "987654321098765432"
}Error Handling
FIELD_MISSING— Triggered if the Bot Token, Guild ID, or User ID is missing.SECRET_RETRIEVE_ERROR— Triggered if the Bot Token secret cannot be retrieved.INVALID_ROLE_IDS— Triggered if the provided list of roles is empty or invalid.API_REQUEST_FAILED— Triggered if the request to Discord fails.DISCORD_ERROR_[code]— Triggered if Discord returns an API error (e.g.,404if the user or role doesn't exist).
Example
- Scenario: Remove a "Trial" role after 7 days.
- Setup Block:
- Bot Token:
{SEC_DISCORD_BOT}. - Guild ID:
1234567890. - User ID:
{request.body.user_id}. - Role IDs:
["111222333444"]. - Audit Log Reason: "Trial period expired".
- Bot Token:
- Result: The role is removed from the user in Discord.
