diff options
Diffstat (limited to 'src/framework')
| -rw-r--r-- | src/framework/configuration.rs | 28 | ||||
| -rw-r--r-- | src/framework/mod.rs | 2 |
2 files changed, 29 insertions, 1 deletions
diff --git a/src/framework/configuration.rs b/src/framework/configuration.rs index 28e1af5..2acf6b3 100644 --- a/src/framework/configuration.rs +++ b/src/framework/configuration.rs @@ -57,6 +57,8 @@ pub struct Configuration { pub owners: HashSet<UserId>, #[doc(hidden)] pub prefixes: Vec<String>, + #[doc(hidden)] + pub delimeter: String, } impl Configuration { @@ -367,6 +369,30 @@ impl Configuration { self } + + /// Sets a delimeter to be used when splitting the content after a command. + /// + /// # Examples + /// + /// Have the args be seperated by a comma and a 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 + /// .delimeter(", "))); + /// ``` + pub fn delimeter(mut self, delimeter: &str) -> Self { + self.delimeter = delimeter.to_string(); + + self + } } impl Default for Configuration { @@ -376,6 +402,7 @@ impl Default for Configuration { /// - **depth** to `5` /// - **on_mention** to `false` (basically) /// - **prefix** to `None` + /// - **delimeter** to " " fn default() -> Configuration { Configuration { depth: 5, @@ -390,6 +417,7 @@ impl Default for Configuration { disabled_commands: HashSet::default(), allow_dm: true, ignore_webhooks: true, + delimeter: " ".to_string(), } } } diff --git a/src/framework/mod.rs b/src/framework/mod.rs index 9206040..ce484e4 100644 --- a/src/framework/mod.rs +++ b/src/framework/mod.rs @@ -937,7 +937,7 @@ impl ::Framework for BuiltinFramework { utils::parse_quotes(&content[command_length..]) } else { content[command_length..] - .split_whitespace() + .split(&self.configuration.delimeter) .map(|arg| arg.to_owned()) .collect::<Vec<String>>() } |