diff options
| author | acdenisSK <[email protected]> | 2017-08-12 19:30:35 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-08-12 19:30:35 +0200 |
| commit | fdfb1846083165629feca81b5169ceaf331289c5 (patch) | |
| tree | 7dcdabb33703006edb00e326c968fb44a7a888b6 /src/framework/configuration.rs | |
| parent | Add support for custom delimeters (diff) | |
| download | serenity-fdfb1846083165629feca81b5169ceaf331289c5.tar.xz serenity-fdfb1846083165629feca81b5169ceaf331289c5.zip | |
Rewamp the custom delimeter functionality to support more
Diffstat (limited to 'src/framework/configuration.rs')
| -rw-r--r-- | src/framework/configuration.rs | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/framework/configuration.rs b/src/framework/configuration.rs index 2acf6b3..a6d0440 100644 --- a/src/framework/configuration.rs +++ b/src/framework/configuration.rs @@ -58,7 +58,7 @@ pub struct Configuration { #[doc(hidden)] pub prefixes: Vec<String>, #[doc(hidden)] - pub delimeter: String, + pub delimeters: Vec<String>, } impl Configuration { @@ -389,7 +389,31 @@ impl Configuration { /// .delimeter(", "))); /// ``` pub fn delimeter(mut self, delimeter: &str) -> Self { - self.delimeter = delimeter.to_string(); + self.delimeters.push(delimeter.to_string()); + + self + } + + /// Sets multiple delimeters to be used when splitting the content after a command. + /// + /// # Examples + /// + /// Have the args be seperated by a comma and a space; and a regular space: + /// + /// ```rust + /// # use serenity::prelude::*; + /// # struct Handler; + /// # + /// # impl EventHandler for Handler {} + /// # let mut client = Client::new("token", Handler); + /// # + /// use serenity::framework::BuiltinFramework; + /// + /// client.with_framework(BuiltinFramework::new().configure(|c| c + /// .delimeters(vec![", ", " "]))); + /// ``` + pub fn delimeters(mut self, delimeters: Vec<&str>) -> Self { + self.delimeters.extend(delimeters.into_iter().map(|s| s.to_string())); self } @@ -402,7 +426,7 @@ impl Default for Configuration { /// - **depth** to `5` /// - **on_mention** to `false` (basically) /// - **prefix** to `None` - /// - **delimeter** to " " + /// - **delimeters** to vec![" "] fn default() -> Configuration { Configuration { depth: 5, @@ -417,7 +441,7 @@ impl Default for Configuration { disabled_commands: HashSet::default(), allow_dm: true, ignore_webhooks: true, - delimeter: " ".to_string(), + delimeters: vec![" ".to_string()], } } } |