FluxyAPIFluxyAPI
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

FieldRequiredDescription
Bot TokenThe secret variable containing your Discord Bot Token.
Guild IDThe unique ID of the Discord Server.
User IDThe unique ID of the User to remove roles from.
Role IDsA list of one or more Role IDs to remove.
Audit Log ReasonAn optional message explaining why the roles were removed.
Output VariableStores 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., 404 if the user or role doesn't exist).

Example

  1. Scenario: Remove a "Trial" role after 7 days.
  2. 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".
  3. Result: The role is removed from the user in Discord.

On this page