diff options
| author | acdenisSK <[email protected]> | 2018-06-21 00:00:47 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2018-06-21 00:01:01 +0200 |
| commit | 10f7548d4d57864b599dd7a760d2609144a2ec63 (patch) | |
| tree | 542627acf097b2761f0639ba117007f47adab071 /src/framework | |
| parent | Merge pull request #337 from Lakelezz/help-for-all-visible-commands (diff) | |
| download | serenity-10f7548d4d57864b599dd7a760d2609144a2ec63.tar.xz serenity-10f7548d4d57864b599dd7a760d2609144a2ec63.zip | |
Remove slight repetition
Diffstat (limited to 'src/framework')
| -rw-r--r-- | src/framework/standard/command.rs | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/src/framework/standard/command.rs b/src/framework/standard/command.rs index c9dad59..c587733 100644 --- a/src/framework/standard/command.rs +++ b/src/framework/standard/command.rs @@ -338,17 +338,12 @@ pub fn positions(ctx: &mut Context, msg: &Message, conf: &Configuration) -> Opti if let Some(mention_end) = find_mention_end(&msg.content, conf) { positions.push(mention_end); return Some(positions); - } else if let Some(ref func) = conf.dynamic_prefix { - if let Some(x) = func(ctx, msg) { - if msg.content.starts_with(&x) { - positions.push(x.chars().count()); - } - } else { - for n in &conf.prefixes { - if msg.content.starts_with(n) { - positions.push(n.chars().count()); - } - } + } + + // Dynamic prefixes, if present and suitable, always have a higher priority. + if let Some(x) = conf.dynamic_prefix.as_ref().and_then(|f| f(ctx, msg)) { + if msg.content.starts_with(&x) { + positions.push(x.chars().count()); } } else { for n in &conf.prefixes { @@ -356,7 +351,7 @@ pub fn positions(ctx: &mut Context, msg: &Message, conf: &Configuration) -> Opti positions.push(n.chars().count()); } } - }; + } if positions.is_empty() { return None; |