Trait twilight_interactions::command::CommandModel [−][src]
pub trait CommandModel: Sized {
fn from_interaction(data: CommandData) -> Result<Self, ParseError>;
}Expand description
Parse CommandData into a concrete type.
This trait represent a slash command model, that can be initialized
from a CommandData. See the module-level documentation to learn more.
Derive macro
A derive macro is provided to implement this trait. The macro only works
with structs with named fields where all field types implement CommandOption.
Macro attributes
The macro provide a #[command] attribute to configure generated code.
Field parameters:
#[command(rename = "")]: use a different name for the field when parsing.
Example
use twilight_interactions::command::{CommandModel, ResolvedUser};
#[derive(CommandModel)]
struct HelloCommand {
message: String,
user: Option<ResolvedUser>
}Required methods
fn from_interaction(data: CommandData) -> Result<Self, ParseError>
fn from_interaction(data: CommandData) -> Result<Self, ParseError>
Construct this type from a CommandData.