pub struct CommandParserConfig<'a> { /* private fields */ }
twilight-http
or twilight-gateway
Expand description
Configuration for a Parser
.
Implementationsยง
Sourceยงimpl<'a> CommandParserConfig<'a>
impl<'a> CommandParserConfig<'a>
Sourcepub const fn new() -> Self
๐Deprecated since 0.8.1: use interactions via twilight-http
or twilight-gateway
pub const fn new() -> Self
twilight-http
or twilight-gateway
Creates a fresh default configuration with no commands or prefixes.
Sourcepub fn commands(&self) -> Commands<'_> โ
๐Deprecated since 0.8.1: use interactions via twilight-http
or twilight-gateway
pub fn commands(&self) -> Commands<'_> โ
twilight-http
or twilight-gateway
Returns an iterator of immutable references to the commands.
Sourcepub fn commands_mut(&mut self) -> CommandsMut<'_> โ
๐Deprecated since 0.8.1: use interactions via twilight-http
or twilight-gateway
pub fn commands_mut(&mut self) -> CommandsMut<'_> โ
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.
Sourcepub fn prefixes(&self) -> Prefixes<'_> โ
๐Deprecated since 0.8.1: use interactions via twilight-http
or twilight-gateway
pub fn prefixes(&self) -> Prefixes<'_> โ
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.
Sourcepub fn prefixes_mut(&'a mut self) -> PrefixesMut<'a> โ
๐Deprecated since 0.8.1: use interactions via twilight-http
or twilight-gateway
pub fn prefixes_mut(&'a mut self) -> PrefixesMut<'a> โ
twilight-http
or twilight-gateway
Returns an iterator of mutable references to the prefixes.
Sourcepub 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
pub fn add_command( &mut self, name: impl Into<String>, case_sensitive: bool, ) -> bool
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());
Sourcepub fn remove_command(&mut self, command: impl AsRef<str>)
๐Deprecated since 0.8.1: use interactions via twilight-http
or twilight-gateway
pub fn remove_command(&mut self, command: impl AsRef<str>)
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);
Sourcepub 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
pub fn add_prefix(&mut self, prefix: impl Into<Cow<'a, str>>) -> bool
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());
Sourcepub 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
pub fn remove_prefix( &mut self, prefix: impl Into<Cow<'a, str>>, ) -> Option<Cow<'a, str>>
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>
impl<'a> Clone for CommandParserConfig<'a>
Sourceยงfn clone(&self) -> CommandParserConfig<'a>
fn clone(&self) -> CommandParserConfig<'a>
1.0.0 ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more