Moved handler.func.is_none check to the top
This commit is contained in:
		@@ -21,6 +21,11 @@ where
 | 
			
		||||
    ) -> BoxFuture<'a, crate::Result<Option<Message>>>,
 | 
			
		||||
{
 | 
			
		||||
    let mut handler = next.lock().await;
 | 
			
		||||
    if handler.func.is_none() {
 | 
			
		||||
        let _ = dialogue.exit().await;
 | 
			
		||||
        return Err(HandlerUsed.into());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    delete_optional(&bot, handler.previous.as_ref()).await;
 | 
			
		||||
 | 
			
		||||
    let text = match msg.text() {
 | 
			
		||||
@@ -40,11 +45,6 @@ where
 | 
			
		||||
        return Ok(());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if handler.func.is_none() {
 | 
			
		||||
        let _ = dialogue.exit().await;
 | 
			
		||||
        return Err(HandlerUsed.into());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if let Some(failure_message) = check(&bot, &msg, &db, text).await? {
 | 
			
		||||
        handler.previous = Some(failure_message);
 | 
			
		||||
        return Ok(());
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,13 @@ pub async fn get_existing_name(
 | 
			
		||||
    next: PackagedHandler<String>,
 | 
			
		||||
) -> crate::Result<()> {
 | 
			
		||||
    let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
 | 
			
		||||
 | 
			
		||||
    let mut handler = next.lock().await;
 | 
			
		||||
    if handler.func.is_none() {
 | 
			
		||||
        let _ = dialogue.exit().await;
 | 
			
		||||
        return Err(HandlerUsed.into());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    delete_optional(&bot, handler.previous.as_ref()).await;
 | 
			
		||||
 | 
			
		||||
    let text = match msg.text() {
 | 
			
		||||
@@ -54,11 +60,6 @@ pub async fn get_existing_name(
 | 
			
		||||
        return Ok(());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if handler.func.is_none() {
 | 
			
		||||
        let _ = dialogue.exit().await;
 | 
			
		||||
        return Err(HandlerUsed.into());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if let Some(failure_message) = check_name(&bot, &msg, &db, text, user_id).await? {
 | 
			
		||||
        handler.previous = Some(failure_message);
 | 
			
		||||
        return Ok(());
 | 
			
		||||
 
 | 
			
		||||
@@ -114,7 +114,13 @@ pub async fn get_user(
 | 
			
		||||
    next: PackagedHandler<User>,
 | 
			
		||||
) -> crate::Result<()> {
 | 
			
		||||
    let user_id = msg.from().ok_or(NoUserInfo)?.id.0;
 | 
			
		||||
 | 
			
		||||
    let mut handler = next.lock().await;
 | 
			
		||||
    if handler.func.is_none() {
 | 
			
		||||
        let _ = dialogue.exit().await;
 | 
			
		||||
        return Err(HandlerUsed.into());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    delete_optional(&bot, handler.previous.as_ref()).await;
 | 
			
		||||
 | 
			
		||||
    if let Some("/cancel") = msg.text().map(str::trim) {
 | 
			
		||||
@@ -125,11 +131,6 @@ pub async fn get_user(
 | 
			
		||||
        return Ok(());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if handler.func.is_none() {
 | 
			
		||||
        let _ = dialogue.exit().await;
 | 
			
		||||
        return Err(HandlerUsed.into());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let document = match msg.document() {
 | 
			
		||||
        Some(document) => document,
 | 
			
		||||
        None => {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user