#[app]Available on crate feature
macros only.Expand description
Collects Routes into an App, the handler an Adapter serves. See
Getting started and Platforms.
Makes a unit struct an App: the Interaction Handler routing to the Commands, Groups, Component
and Modal Handlers, Views and other Apps listed in handlers(..), in any mix and order.
ⓘ
/// Everything the bot serves
#[app(handlers(ping, echo, Admin, counter_click, on_feedback, Card, Moderation),
events = MyEvents, errors = render_error)]
pub struct Bot;- Implements
InteractionHandler(for every State all listed items accept),EventHandlerandCommandSetDefinition(for Sync);Bot.with_fallback(handler)sends what nothing listed handles (components, modals, autocomplete, commands) tohandler - Apps nest: a module can declare its own
#[app]next to its handlers and be listed in the root one events = MyEvents(a unit struct implementingEventHandler): handles Webhook Events; at most one App in a tree sets iterrors = render_error(afn(&HandlerError) -> InteractionResponse, anErrorRenderer): the response handler errors are answered with, here and from deferred work, instead ofHandlerError::response’s ephemeral text; at most one App in a tree sets it, and the root uses it for the whole tree
Two Commands with the same name and type, two handlers with the same custom_id prefix, more
Commands than Discord allows in one Scope, a placed sub-View with handlers that is not
listed, or two Apps setting events (or errors) fail to compile.