Error Types
Command Errors
Errors that occur during command execution inherit fromdiscord.ext.commands.CommandError:
CommandNotFound- Command doesn’t existMissingRequiredArgument- Required parameter not providedBadArgument- Argument conversion failedCheckFailure- Command check failedCommandOnCooldown- Command is on cooldownMissingPermissions- User lacks permissionsBotMissingPermissions- Bot lacks permissionsCommandInvokeError- Error during command execution
Application Command Errors
Errors for slash commands inherit fromdiscord.ApplicationCommandError:
ApplicationCommandInvokeError- Error during slash command executionCheckFailure- Check failed for application command
Discord API Errors
Errors from Discord API inherit fromdiscord.DiscordException:
Forbidden- Missing permissions (403)NotFound- Resource not found (404)HTTPException- Generic HTTP errorConnectionClosed- WebSocket connection closed
Global Error Handlers
Command Error Handler
Handle all prefix command errors:Application Command Error Handler
Handle slash command errors:Local Error Handlers
Per-Command Error Handler
Handle errors for specific commands:Slash Command Error Handler
Cog Error Handlers
Handle errors for all commands in a cog:Interaction Error Handling
Button/Select Menu Errors
Modal Errors
Custom Exceptions
Create custom exceptions for your bot:Error Logging
Basic Logging
Log to Channel
Graceful Degradation
Fallback Responses
Permission Handling
Best Practices
Common Patterns
Retry Logic
Error Context Manager
See Also
- Slash Commands - Error handling for slash commands
- Prefix Commands - Error handling for prefix commands
- UI Components - Error handling for interactions
