Skip to content

Commit

Permalink
Check after prefix parsing
Browse files Browse the repository at this point in the history
Otherwise the framework might return dispatch errors for messages by any bot or webhook.
  • Loading branch information
arqunis committed Jul 22, 2019
1 parent 709a21b commit b7b3a85
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/framework/standard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,18 +598,12 @@ impl StandardFramework {

impl Framework for StandardFramework {
fn dispatch(&mut self, mut ctx: Context, msg: Message, threadpool: &ThreadPool) {
if let Some(error) = self.should_fail_common(&msg) {

if let Some(dispatch) = &self.dispatch {
dispatch(&mut ctx, &msg, error);
}

return;
}

let (prefix, rest) = parse_prefix(&mut ctx, &msg, &self.config);

if prefix != Prefix::None && rest.trim().is_empty() {

if let Some(prefix_only) = &self.prefix_only {
let prefix_only = Arc::clone(&prefix_only);
let msg = msg.clone();
Expand All @@ -623,6 +617,7 @@ impl Framework for StandardFramework {
}

if prefix == Prefix::None && !(self.config.no_dm_prefix && msg.is_private()) {

if let Some(normal) = &self.normal_message {
let normal = Arc::clone(&normal);
let msg = msg.clone();
Expand All @@ -635,6 +630,15 @@ impl Framework for StandardFramework {
return;
}

if let Some(error) = self.should_fail_common(&msg) {

if let Some(dispatch) = &self.dispatch {
dispatch(&mut ctx, &msg, error);
}

return;
}

let invoke = match parse_command(
rest,
&msg,
Expand Down

0 comments on commit b7b3a85

Please sign in to comment.