aboutsummaryrefslogtreecommitdiff
path: root/src/framework
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-08-12 15:26:19 +0200
committeracdenisSK <[email protected]>2017-08-12 15:26:19 +0200
commit125c1b8feff65ed86136ca0c3b75cdfa073aefc3 (patch)
tree36865e2986488377a0a41fa59f506fc8acce1ac1 /src/framework
parentDon't do any other fuzz about private channels if they're already in the cache (diff)
downloadserenity-125c1b8feff65ed86136ca0c3b75cdfa073aefc3.tar.xz
serenity-125c1b8feff65ed86136ca0c3b75cdfa073aefc3.zip
Add support for custom delimeters
Diffstat (limited to 'src/framework')
-rw-r--r--src/framework/configuration.rs28
-rw-r--r--src/framework/mod.rs2
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>>()
}