Middleware
Class
Before, after and error hooks, filterable per command.
from discord_interactions.slash import MiddlewareConstructor
Middleware( name: str, before: Callable[[SlashContext], Awaitable[bool | None]] | None = None, after: Callable[[SlashContext, Any, Exception | None], Awaitable[None]] | None = None, on_error: Callable[[SlashContext, Exception], Awaitable[bool | None]] | None = None, priority: int = 100, commands: List[str] | None = None, exclude_commands: List[str] | None = None,)| Name | Type | Default | Description |
|---|---|---|---|
name | str | required | |
before | Callable[[SlashContext], Awaitable[bool | None]] | None | None | |
after | Callable[[SlashContext, Any, Exception | None], Awaitable[None]] | None | None | |
on_error | Callable[[SlashContext, Exception], Awaitable[bool | None]] | None | None | |
priority | int | 100 | |
commands | List[str] | None | None | |
exclude_commands | List[str] | None | None |
Properties
| Name | Type | Description |
|---|---|---|
name | str | |
before | Callable[[SlashContext], Awaitable[bool | None]] | None | |
after | Callable[[SlashContext, Any, Exception | None], Awaitable[None]] | None | |
on_error | Callable[[SlashContext, Exception], Awaitable[bool | None]] | None | |
priority | int | |
commands | List[str] | None | |
exclude_commands | List[str] | None |
Methods
should_apply
def should_apply(command_name: str) -> boolCheck if this middleware should apply to a command.