fn math(ctx: &mut Context, msg: &Message, args: Args) -> CommandResult {
    let mut namespace = fasteval::EmptyNamespace;
    let value = fasteval::ez_eval(&args.rest(), &mut namespace);

    match value {
        Ok(value) => msg
            .channel_id
            .say(&ctx.http, value)
            .map_or_else(|e| Err(CommandError(e.to_string())), |_| Ok(())),

        Err(err) => match err {
            fastevalError::Undefined(variable) => {
                let content = content_safe(&ctx, variable, &ContentSafeOptions::default());
                msg.channel_id
                    .say(
                        &ctx.http,
                        format!(
                            "Unknown variable: `{}`\nPS: Variables are unsupported",
                            content
                        ),
                    )
                    .map_or_else(|e| Err(CommandError(e.to_string())), |_| Ok(()))
            }
            _ => {
                let content =
                    content_safe(&ctx, format!("{:#?}", err), &ContentSafeOptions::default());
                msg.channel_id
                    .say(&ctx.http, content)
                    .map_or_else(|e| Err(CommandError(e.to_string())), |_| Ok(()))
            }
        },
    }
}
/// For fun with math, does not currently support variables*
/// *(There are plans to change that in the future!)
For fun with math, does not currently support variables
(There are plans to change that in the future!)
For fun with math does not currently support variables ( There are plans to change that in the future! )
fn math(ctx: &mut Context, msg: &Message, args: Args) -> CommandResult {
    let mut namespace = fasteval::EmptyNamespace;
    let value = fasteval::ez_eval(&args.rest(), &mut namespace);
    match value {
        Ok(value) => msg
            .channel_id
            .say(&ctx.http, value)
            .map_or_else(|e| Err(CommandError(e.to_string())), |_| Ok(())),
        Err(err) => match err {
            fastevalError::Undefined(variable) => {
                let content = content_safe(&ctx, variable, &ContentSafeOptions::default());
                msg.channel_id
                    .say(
                        &ctx.http,
                        format!(
                            "Unknown variable: `{}`\nPS: Variables are unsupported",
                            content
                        ),
                    )
                    .map_or_else(|e| Err(CommandError(e.to_string())), |_| Ok(()))
            }
            _ => {
                let content =
                    content_safe(&ctx, format!("{:#?}", err), &ContentSafeOptions::default());
                msg.channel_id
                    .say(&ctx.http, content)
                    .map_or_else(|e| Err(CommandError(e.to_string())), |_| Ok(()))
            }
        },
    }
}
fn math ( ctx : & mut Context , msg : & Message , args : Args ) -> CommandResult { let mut namespace = fasteval :: EmptyNamespace ; let value = fasteval :: ez_eval ( & args . rest ( ) , & mut namespace ) ; match value { Ok ( value ) => msg . channel_id . say ( & ctx . http , value ) . map_or_else ( | e | Err ( CommandError ( e . to_string ( ) ) ) , | _ | Ok ( ( ) ) ) , Err ( err ) => match err { fastevalError :: Undefined ( variable ) => { let content = content_safe ( & ctx , variable , & ContentSafeOptions :: default ( ) ) ; msg . channel_id . say ( & ctx . http , format ! ( " \n " content ) , ) . map_or_else ( | e | Err ( CommandError ( e . to_string ( ) ) ) , | _ | Ok ( ( ) ) ) } _ => { let content = content_safe ( & ctx , format ! ( " " err ) , & ContentSafeOptions :: default ( ) ) ; msg . channel_id . say ( & ctx . http , content ) . map_or_else ( | e | Err ( CommandError ( e . to_string ( ) ) ) , | _ | Ok ( ( ) ) ) } } , } }
For fun with math, does not currently support variables
(There are plans to change that in the future!)
For fun with math does not currently support variables ( There are plans to change that in the future! )
ctx
&mut Context
msg
&Message
args
Args
ctx
&mut Context
msg
&Message
args
Args