Merge pull request #9 from minneelyyyy/dev
use poise builtin codeblock type
This commit is contained in:
@@ -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), "<eval>");
|
||||
#[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), "<eval>");
|
||||
|
||||
let values = runtime.values().fold(Ok(String::new()), |acc, v| {
|
||||
if acc.is_err() {
|
||||
|
||||
Reference in New Issue
Block a user