Skip to content

cog

Comprehensive error handler for Discord commands.

Classes:

  • ErrorHandler

    Centralized error handling for both prefix and slash commands.

Functions:

  • setup

    Cog setup for error handler.

Classes

ErrorHandler

Python
ErrorHandler(bot: Tux)

Bases: Cog

Centralized error handling for both prefix and slash commands.

Initialize the error handler cog.

Parameters:

  • bot (Tux) –

    The bot instance to attach this cog to.

Methods:

Functions

cog_load async
Python
cog_load() -> None

Override app command error handler.

cog_unload async
Python
cog_unload() -> None

Restore original app command error handler.

cog_reload async
Python
cog_reload() -> None

Handle cog reload - force reload imported modules.

_handle_error async
Python
_handle_error(source: Context[Tux] | Interaction, error: Exception) -> None

Handle errors for commands and interactions.

_set_sentry_context
Python
_set_sentry_context(source: Context[Tux] | Interaction, error: Exception) -> None

Set enhanced Sentry context for error reporting.

_get_error_config
Python
_get_error_config(error: Exception) -> ErrorHandlerConfig

Get configuration for error type.

Returns:

_log_error
Python
_log_error(error: Exception, config: ErrorHandlerConfig) -> None

Log error with appropriate level.

_send_error_response async
Python
_send_error_response(
    source: Context[Tux] | Interaction, embed: Embed, config: ErrorHandlerConfig
) -> None

Send error response to user.

on_command_error async
Python
on_command_error(ctx: Context[Tux], error: CommandError) -> None

Handle prefix command errors.

on_app_command_error async
Python
on_app_command_error(interaction: Interaction[Tux], error: AppCommandError) -> None

Handle app command errors.

Functions

setup async

Python
setup(bot: Tux) -> None

Cog setup for error handler.

Parameters:

  • bot (Tux) –

    The bot instance.