composure_macros
The macros behind Composure: write a Discord command as a function, a message as markup.
Don't depend on this crate directly: enable
composure'smacrosfeature, which re-exports everything here.
use ;
/// Repeat some text
/// A button that counts its clicks, no database required
;
| Macro | What it gives you |
|---|---|
#[command] |
A slash or context-menu command from a function: Options from its typed parameters, the description from its doc comment |
#[group] |
Subcommands: /mod ban, /mod kick |
#[autocomplete] |
Suggestions while the user types |
#[derive(Choice)] |
An enum as a fixed set of choices |
#[component], #[modal] |
Handlers for buttons, selects and modal submits, with state carried in the custom_id |
#[derive(Modal)] |
A form whose submit arrives as your struct |
rsx! |
JSX-like markup for Components V2 messages and modals |
#[view] |
A reusable layout with inline event handlers |
#[app] |
Collects everything into the handler an Adapter serves |
Mistakes are caught at compile time with errors that say what to do: a missing description, an Option bound outside its type, two commands with the same name, a button in the wrong place, a modal input without a matching parameter.
Learn them in the guide; every
rsx! tag and attribute is in the
Views reference.
License
Licensed under the Apache License, Version 2.0.