Skip to content

Commit

Permalink
Call the should_fail_common check earlier
Browse files Browse the repository at this point in the history
This avoids parsing a prefix when the message came from a bot or webhook.
  • Loading branch information
arqunis committed Sep 14, 2020
1 parent 323875f commit bab4b24
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/framework/standard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,14 @@ impl StandardFramework {
impl Framework for StandardFramework {
#[instrument(skip(self, ctx))]
async fn dispatch(&self, mut ctx: Context, msg: Message) {
if let Some(error) = self.should_fail_common(&msg) {
if let Some(dispatch) = &self.dispatch {
dispatch(&mut ctx, &msg, error).await;
}

return;
}

let mut stream = Stream::new(&msg.content);

stream.take_while_char(|c| c.is_whitespace());
Expand All @@ -638,14 +646,6 @@ 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).await;
}

return;
}

let invocation = parse::command(
&ctx,
&msg,
Expand Down

0 comments on commit bab4b24

Please sign in to comment.