Remove Role Member
Removes a role from a Discord server member.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Client Id - The Discord bot client identifier from the Connect node (optional if Bot Token provided).
- Server Id - The Discord server (guild) ID where the role removal will occur.
- User Id - The ID of the Discord user to remove the role from.
- Role Id - The ID of the role to remove.
Options
- Bot Token - Discord bot token credential (optional if using Client ID from Connect node).
How It Works
The Remove Role Member node removes a role from a server member. When executed, the node:
- Authenticates using either Client ID or direct bot token
- Validates the server ID, user ID, and role ID
- Sends a role removal request to Discord API
- Removes the role from the specified user
Requirements
- Active Discord bot session (Client ID) or bot token credentials
- Valid server ID, user ID, and role ID
- Manage Roles permission in the server
- Bot's highest role must be higher than the role being removed
- The user must currently have the role
Error Handling
The node will return specific errors in the following cases:
- ErrInvalidArg - Client ID or bot token missing/invalid
- ErrInvalidArg - Server ID is empty
- ErrInvalidArg - User ID is empty
- ErrInvalidArg - Role ID is empty
- Discord API errors (missing permissions, role hierarchy issues, user doesn't have role, etc.)
Example: Remove Temporary Role
Inputs:
- Server Id: "123456789012345678"
- User Id: "987654321098765432"
- Role Id: "555555555555555555"
Result: User loses the specified role.
Example: Timeout Role Removal
Flow:
1. Add Role Member (Muted role)
2. Delay 600 seconds (10 minutes)
3. Remove Role Member (Muted role)
- Server Id: {{server_id}}
- User Id: {{user_id}}
- Role Id: {{muted_role_id}}
4. Send message: "Your timeout has expired."
Result: Temporary mute that auto-expires.
Example: Remove Role on Command
Flow:
1. Interaction In (command: /leave-event) → interaction
2. Remove Role Member
- Server Id: {{interaction.GuildID}}
- User Id: {{interaction.Member.User.ID}}
- Role Id: "777777777777777777" (Event Participant)
3. Interaction Out: "You've been removed from the event."
Result: Users can opt out of events by removing their role.
Example: Moderation Action
Flow:
1. Interaction In (command: /warn @user) → interaction
2. Check warnings count
3. If warnings >= 3:
- Remove Role Member (Member role)
- Add Role Member (Restricted role)
4. Log moderation action
Result: Remove privileges after multiple warnings.
Example: Access Revocation
Flow:
1. Check subscription status
2. If subscription expired:
- Remove Role Member
- Role Id: {{premium_role_id}}
- Send Direct Message
- Message: "Your premium access has expired"
Result: Remove premium role when subscription ends.
Getting Role IDs
- Enable Developer Mode in Discord (User Settings > Advanced)
- Right-click on a role in Server Settings > Roles
- Select "Copy ID"
Role Hierarchy
Discord's role hierarchy rules apply:
- Bots can only remove roles lower than their highest role
- The bot's highest role must be above the role being removed
- Server owner can remove any role
- Users with Manage Roles permission still subject to hierarchy
Use Cases
- Timeout systems - Remove mute/timeout roles automatically
- Access expiration - Remove premium/subscriber roles
- Event cleanup - Remove event participant roles after events
- Moderation - Remove roles as punishment
- Opt-out systems - Let users remove optional roles
- Role rotation - Remove old roles before assigning new ones
- Access control - Revoke channel access by removing roles
Bot Permissions Required
- Manage Roles - Required to remove roles
- Bot's role must be higher in hierarchy than the role being removed
Role Removal Behavior
When a role is removed:
- User immediately loses the role's permissions
- Role disappears from the user's role list
- User loses access to role-restricted channels
- User's name color may change if the removed role was providing color
- Audit log records the role removal
Remove Multiple Roles
To remove multiple roles from a user:
1. Remove Role Member (Role 1)
2. Remove Role Member (Role 2)
3. Remove Role Member (Role 3)
Conditional Role Removal
Flow:
1. Get user activity data
2. Condition: activity < 10 AND has_active_role
3. If True:
- Remove Role Member (Active Member role)
4. Send notification about inactivity
Error Handling
Handle cases where the user doesn't have the role:
1. Try:
- Remove Role Member
2. Catch:
- Log: "User didn't have the role"
- Continue
Combined Operations
Remove one role and add another:
1. Remove Role Member (Trial role)
2. Add Role Member (Full Member role)
3. Send congratulations message
Tips and Best Practices
- Verify hierarchy - Ensure bot's role is high enough
- Check permissions - Verify Manage Roles permission
- User validation - Confirm user has the role before attempting removal
- Error handling - Handle cases gracefully when removal fails
- Logging - Log role removals for audit purposes
- Notifications - Notify users when important roles are removed
- Cleanup - Remove temporary roles after they're no longer needed
- Testing - Test role removal in a development server first