From 10f7548d4d57864b599dd7a760d2609144a2ec63 Mon Sep 17 00:00:00 2001 From: acdenisSK Date: Thu, 21 Jun 2018 00:00:47 +0200 Subject: Remove slight repetition --- src/framework/standard/command.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/framework') 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; -- cgit v1.2.3