[][src]Struct twilight_command_parser::CommandBuilder

#[must_use = "If `add` is not called the command will not be added."]pub struct CommandBuilder<'a, 'b> { /* fields omitted */ }

A builder struct for building commands.

The add method needs to be called for the command to be added to the CommandParserConfig.

Note: Commands are not case sensitive by default. Use case_sensitive to enable this.

Examples

use twilight_command_parser::CommandParserConfig;

let mut config = CommandParserConfig::new();
// Adds a case sensitive command to the config.
config.command("ping").case_sensitive().add();
assert_eq!(1, config.commands().len());

Implementations

impl<'a, 'b> CommandBuilder<'a, 'b>[src]

pub fn add(self)[src]

Adds the command to the CommandParserConfig.

pub fn case_sensitive(self) -> Self[src]

Makes the command only match if the case is the same.

Examples

use twilight_command_parser::{CommandParserConfig, Parser};

let mut config = CommandParserConfig::new();
config.add_prefix("!");
config.command("ping").case_sensitive().add();
let parser = Parser::new(config);
assert!(parser.parse("!ping should work").is_some());
assert!(parser.parse("!PiNg shouldn't work").is_none());

pub fn case_insensitive(self) -> Self[src]

Makes the command match regardless of case. This is set by default.

Examples

use twilight_command_parser::{CommandParserConfig, Parser};

let mut config = CommandParserConfig::new();
config.add_prefix("!");
config.command("ping").case_insensitive().add();
let parser = Parser::new(config);
assert!(parser.parse("!ping should work").is_some());
assert!(parser.parse("!PiNg should also work").is_some());

Auto Trait Implementations

impl<'a, 'b> RefUnwindSafe for CommandBuilder<'a, 'b>

impl<'a, 'b> Send for CommandBuilder<'a, 'b>

impl<'a, 'b> Sync for CommandBuilder<'a, 'b>

impl<'a, 'b> Unpin for CommandBuilder<'a, 'b> where
    'b: 'a, 

impl<'a, 'b> !UnwindSafe for CommandBuilder<'a, 'b>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.