diff --git a/src/commands/eval.rs b/src/commands/eval.rs index ec75700..ae3e5ae 100644 --- a/src/commands/eval.rs +++ b/src/commands/eval.rs @@ -2,28 +2,9 @@ use crate::common::{Context, Error}; use std::io::Cursor; /// Evaluates a Lamm program -#[poise::command(slash_command, prefix_command, aliases("lamm"))] -pub async fn eval(ctx: Context<'_>, - #[rest] - expr: String) -> Result<(), Error> -{ - let expr = if expr.starts_with("```\n") { - expr.strip_prefix("```\n") - .and_then(|s| s.strip_suffix("```")) - .unwrap_or(&expr) - } else if expr.starts_with("```") { - expr.strip_prefix("```") - .and_then(|s| s.strip_suffix("```")) - .unwrap_or(&expr) - } else if expr.starts_with('`') { - expr.strip_prefix("`") - .and_then(|s| s.strip_suffix("`")) - .unwrap_or(&expr) - } else { - &expr - }; - - let runtime = lamm::Runtime::new(Cursor::new(expr), ""); +#[poise::command(prefix_command, aliases("lamm"))] +pub async fn eval(ctx: Context<'_>, expr: poise::CodeBlock) -> Result<(), Error> { + let runtime = lamm::Runtime::new(Cursor::new(expr.code), ""); let values = runtime.values().fold(Ok(String::new()), |acc, v| { if acc.is_err() {