baptiste0928 / twilight-interactions

Macros and utilities to work with Discord Interactions using twilight.
ISC License
37 stars 7 forks source link

Derive macros for `CreateCommand` #1

Closed baptiste0928 closed 3 years ago

baptiste0928 commented 3 years ago

Create derive macro for the CreateCommand trait. This will introduce a #[command] attribute. All struct fields must be documented (doc comment or desc attribute).

use twilight_interactions::{CommandModel, CreateCommand, ResolvedUser};

/// Say hello with a message
#[derive(CommandModel, CreateCommand)]
#[command(name = "hello", default_permission = true)
struct HelloCommand {
    #[command(desc = "Your message.")
    message: String,
    /// The member to send the message to.
    #[command(rename = "member")
    user: Option<ResolvedUser>
}
baptiste0928 commented 3 years ago

Done! (bbccd7388c3c3105aa9c5ac4ac4917d164c9c275)