MiddlewareStack
Class
Stack of middlewares sorted by priority.
from discord_interactions.slash import MiddlewareStackConstructor
MiddlewareStack()Methods
add
def add(middleware: Middleware) -> NoneAdd a middleware to the stack.
remove
def remove(name: str) -> boolRemove a middleware by name.
run_before
async def run_before(ctx: SlashContext) -> boolRun all before middlewares. Returns False if any middleware blocks execution.
run_after
async def run_after(ctx: SlashContext, result: Any, error: Exception | None) -> NoneRun all after middlewares.
run_error
async def run_error(ctx: SlashContext, error: Exception) -> boolRun error handlers. Returns True if the error was handled.