Struct CommandParserConfig

Source
pub struct CommandParserConfig<'a> { /* private fields */ }
๐Ÿ‘ŽDeprecated since 0.8.1: use interactions via twilight-http or twilight-gateway
Expand description

Configuration for a Parser.

Implementationsยง

Sourceยง

impl<'a> CommandParserConfig<'a>

Source

pub const fn new() -> Self

๐Ÿ‘ŽDeprecated since 0.8.1: use interactions via twilight-http or twilight-gateway

Creates a fresh default configuration with no commands or prefixes.

Source

pub fn commands(&self) -> Commands<'_> โ“˜

๐Ÿ‘ŽDeprecated since 0.8.1: use interactions via twilight-http or twilight-gateway

Returns an iterator of immutable references to the commands.

Source

pub fn commands_mut(&mut self) -> CommandsMut<'_> โ“˜

๐Ÿ‘ŽDeprecated since 0.8.1: use interactions via twilight-http or twilight-gateway

Returns an iterator of mutable references to the commands.

Use the add_command and remove_command methods for an easier way to manage commands.

Source

pub fn prefixes(&self) -> Prefixes<'_> โ“˜

๐Ÿ‘ŽDeprecated since 0.8.1: use interactions via twilight-http or twilight-gateway

Returns an iterator of immutable references to the prefixes.

Use the add_prefix and remove_prefix methods for an easier way to manage prefixes.

Source

pub fn prefixes_mut(&'a mut self) -> PrefixesMut<'a> โ“˜

๐Ÿ‘ŽDeprecated since 0.8.1: use interactions via twilight-http or twilight-gateway

Returns an iterator of mutable references to the prefixes.

Source

pub fn add_command( &mut self, name: impl Into<String>, case_sensitive: bool, ) -> bool

๐Ÿ‘ŽDeprecated since 0.8.1: use interactions via twilight-http or twilight-gateway

Add a command to the list of commands.

ยงExamples

Add a case-sensitive โ€œpingโ€ command:

use twilight_command_parser::CommandParserConfig;

let mut config = CommandParserConfig::new();
config.add_command("ping", true);
assert_eq!(1, config.commands().len());
Source

pub fn remove_command(&mut self, command: impl AsRef<str>)

๐Ÿ‘ŽDeprecated since 0.8.1: use interactions via twilight-http or twilight-gateway

Removes a command from the list of commands.

Any commands that would match the command provided are removed.

ยงExamples
use twilight_command_parser::CommandParserConfig;

let mut config = CommandParserConfig::new();
config.add_command("ping", true);
config.add_command("PING", false);
assert_eq!(2, config.commands().len());

// Now remove it and verify that there are no commands.
config.remove_command("ping");
assert_eq!(config.commands().len(), 0);
Source

pub fn add_prefix(&mut self, prefix: impl Into<Cow<'a, str>>) -> bool

๐Ÿ‘ŽDeprecated since 0.8.1: use interactions via twilight-http or twilight-gateway

Adds a prefix to the list of prefixes.

ยงExamples
use twilight_command_parser::CommandParserConfig;

let mut config = CommandParserConfig::new();
config.add_prefix("!");
assert_eq!(1, config.prefixes().len());
Source

pub fn remove_prefix( &mut self, prefix: impl Into<Cow<'a, str>>, ) -> Option<Cow<'a, str>>

๐Ÿ‘ŽDeprecated since 0.8.1: use interactions via twilight-http or twilight-gateway

Removes a prefix from the list of prefixes.

Returns whether a prefix with the name was removed.

ยงExamples
use twilight_command_parser::CommandParserConfig;

let mut config = CommandParserConfig::new();
config.add_prefix("!");
config.add_prefix("~");
assert_eq!(2, config.prefixes().len());

// Now remove one and verify that there is only 1 prefix.
config.remove_prefix("!");
assert_eq!(1, config.prefixes().len());

Trait Implementationsยง

Sourceยง

impl<'a> Clone for CommandParserConfig<'a>

Sourceยง

fn clone(&self) -> CommandParserConfig<'a>

Returns a duplicate of the value. Read more
1.0.0 ยท Sourceยง

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Sourceยง

impl<'a> Debug for CommandParserConfig<'a>

Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Sourceยง

impl<'a> Default for CommandParserConfig<'a>

Sourceยง

fn default() -> CommandParserConfig<'a>

Returns the โ€œdefault valueโ€ for a type. Read more

Auto Trait Implementationsยง

Blanket Implementationsยง

Sourceยง

impl<T> Any for T
where T: 'static + ?Sized,

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

Sourceยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Sourceยง

impl<T> CloneToUninit for T
where T: Clone,

Sourceยง

unsafe fn clone_to_uninit(&self, dest: *mut u8)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

Sourceยง

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Sourceยง

impl<T> ToOwned for T
where T: Clone,

Sourceยง

type Owned = T

The resulting type after obtaining ownership.
Sourceยง

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Sourceยง

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Sourceยง

type Error = Infallible

The type returned in the event of a conversion error.
Sourceยง

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Sourceยง

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

The type returned in the event of a conversion error.
Sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.