discord-interactions.py

MiddlewareStack

Class

Stack of middlewares sorted by priority.

from discord_interactions.slash import MiddlewareStack

Constructor

MiddlewareStack()

Methods

add

def add(middleware: Middleware) -> None

Add a middleware to the stack.

remove

def remove(name: str) -> bool

Remove a middleware by name.

run_before

async def run_before(ctx: SlashContext) -> bool

Run all before middlewares. Returns False if any middleware blocks execution.

run_after

async def run_after(ctx: SlashContext, result: Any, error: Exception | None) -> None

Run all after middlewares.

run_error

async def run_error(ctx: SlashContext, error: Exception) -> bool

Run error handlers. Returns True if the error was handled.

Type a name: create_button, ModalBuilder, cooldown.