Skip to content

Commit

Permalink
Do not to " " if none of the provided delimiters are found (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhelwig authored and arqunis committed Oct 7, 2017
1 parent 91c8ec4 commit 3a4cb18
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 7 additions & 2 deletions src/framework/standard/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl<E: StdError> From<E> for Error<E> {
fn from(e: E) -> Self {
Error::Parse(e)
}
}
}

impl<E: StdError> StdError for Error<E> {
fn description(&self) -> &str {
Expand Down Expand Up @@ -60,7 +60,12 @@ pub struct Args {
}

impl Args {
pub fn new(message: &str, delimiter: &str) -> Self {
pub fn new(message: &str, possible_delimiters: Vec<String>) -> Self {
let delimiter = possible_delimiters
.iter()
.find(|&d| message.contains(d))
.map_or(possible_delimiters[0].as_str(), |s| s.as_str());

let split = if message.trim().is_empty() {
Vec::new()
} else {
Expand Down
8 changes: 1 addition & 7 deletions src/framework/standard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,13 +901,7 @@ impl Framework for StandardFramework {
let mut content = message.content[position..].trim();
content = content[command_length..].trim();

let delimiter = self.configuration
.delimiters
.iter()
.find(|&d| content.contains(d))
.map_or(" ", |s| s.as_str());

Args::new(&content, delimiter)
Args::new(&content, self.configuration.delimiters.clone())
};

if let Some(error) = self.should_fail(
Expand Down

0 comments on commit 3a4cb18

Please sign in to comment.