Ban
Overview
The /ban command allows moderators to ban members from the server with optional temporary duration. Banned users are removed from the server and cannot rejoin unless unbanned.
Command Details
Permissions Required
User:
BAN_MEMBERSpermissionBot:
BAN_MEMBERSpermission
Command Syntax
/ban member:<@member> reason:<text> [duration:<time>]Parameters
member
User
✅ Yes
The member to ban
reason
String
✅ Yes
The reason for the ban
duration
String
❌ No
Ban duration (e.g., 5m, 1h, 7d, 30d). Leave blank for permanent
Features
1. Temporary Bans
Set an optional duration for automatic unban:
Supports various time formats:
5m,1h,7d,30dAutomatically schedules unban at expiration
Unban is handled by the bot automatically
Tracked in moderation history
2. Role Hierarchy Protection
Moderators cannot ban members with equal or higher roles
Ensures proper permission structure
Prevents abuse of moderation powers
3. DM Notifications
Banned users receive a DM containing:
Server name
Ban reason
Duration (if temporary)
Unban timestamp (if temporary)
Server invite link (for temporary bans)
4. Comprehensive Audit Logging
Records action in moderation history database
Logs to configured audit channel
Includes: moderator, target, reason, duration, timestamp
Tracks active ban status
5. Database Tracking
Updates member record with:
currentlyBannedflag set to trueFull moderation history entry
Duration and expiration tracking
Usage Examples
Example 1: Permanent Ban
Permanently bans the user. They cannot rejoin without an unban.
Example 2: Temporary 7-Day Ban
Bans for 7 days. User is automatically unbanned after expiration.
Example 3: Short Timeout Alternative
1-hour ban for minor offenses (consider using /mute for short timeouts instead).
Example 4: Extended Ban
30-day ban for serious violations.
How It Works
Permission Validation:
Checks moderator has
BAN_MEMBERSpermissionVerifies moderator's role is higher than target's highest role
Ensures bot has permission to ban the target
DM Notification:
Attempts to send DM to user explaining the ban
Includes reason, duration (if any), and invite link (if temporary)
Failure to DM is logged but doesn't prevent the ban
Execute Ban:
Removes user from server immediately
Discord API ban action with reason
Schedule Unban (if temporary):
Calculates expiration timestamp
Schedules automatic unban using bot's scheduling system
Stored in database for persistence across restarts
Database Updates:
Adds entry to moderation history
Sets
currentlyBannedflagRecords moderator, reason, timestamp, duration
Audit Logging:
Posts formatted embed to audit log channel
Includes all relevant details
Moderators and admins can review actions
Duration Format
Accepted duration formats:
Xm
X minutes
30m = 30 minutes
Xh
X hours
12h = 12 hours
Xd
X days
7d = 7 days
Examples:
5m- 5 minutes1h- 1 hour7d- 7 days
Error Handling
The command handles various error scenarios:
Equal/Higher Role: "You cannot ban a member with equal or higher role than yours."
Not Bannable: "I do not have permission to ban this member."
DM Failure: Logged but ban still proceeds
Database Error: Reported to moderator
Automatic Unban
For temporary bans:
Expiration time stored in database
Bot schedules unban task
At expiration:
User is unbanned via Discord API
Moderation history updated (
activeset to false)Audit log entry created
currentlyBannedflag set to false
Related Commands
Unban - Manually unban a user
Kick - Remove without ban (user can rejoin)
Mute - Timeout without removal
Warn - Issue warning without punishment
User Info - View member's moderation history
Configuration
Configure audit logging in config.json:
Best Practices
Always provide detailed reasons - Helps with transparency and appeals
Use temporary bans first - Start with 7d, escalate to permanent if needed
Document repeat offenders - Use
/user-infoto check historyConsider alternatives - Use
/mutefor minor offensesCommunicate with team - Discuss major bans with other moderators
Review history - Check if user has prior offenses
Tips
Temporary bans are ideal for cooling-off periods
Permanent bans should be reserved for severe violations
Always explain the ban reason clearly
Keep your server invite link updated in config
Users can appeal bans through modmail or other channels you set up
Last updated
Was this helpful?