twilight_util::builder

Module command

Source
Available on crate feature builder only.
Expand description

Create a [Command] with a builder.

§Examples

use twilight_model::application::command::CommandType;
use twilight_util::builder::command::{BooleanBuilder, CommandBuilder, StringBuilder};

CommandBuilder::new(
    "blep",
    "Send a random adorable animal photo",
    CommandType::ChatInput,
)
.option(
    StringBuilder::new("animal", "The type of animal")
        .required(true)
        .choices([
            ("Dog", "animal_dog"),
            ("Cat", "animal_cat"),
            ("Penguin", "animal_penguin"),
        ]),
)
.option(BooleanBuilder::new(
    "only_smol",
    "Whether to show only baby animals",
));
use twilight_model::application::command::CommandType;
use twilight_util::builder::command::{CommandBuilder, NumberBuilder};

CommandBuilder::new(
    "birthday",
    "Wish a friend a happy birthday",
    CommandType::ChatInput,
)
.name_localizations([("zh-CN", "生日"), ("el", "γενέθλια")])
.description_localizations([("zh-Cn", "祝你朋友生日快乐")])
.option(
    NumberBuilder::new("age", "Your friend's age")
        .name_localizations([("zh-CN", "岁数")])
        .description_localizations([("zh-CN", "你朋友的岁数")]),
);

Structs§