refactor(client): simplify usage with deref

This commit is contained in:
2025-02-18 21:34:57 -05:00
parent 93a2dda8c6
commit 75d4a9c183
7 changed files with 68 additions and 108 deletions

View File

@@ -59,7 +59,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) {
commands.register(
literal("eval").then(argument("code", string()).executes(|ctx: &Ctx| {
let source = ctx.source.clone();
let code = get_string(ctx, "code").unwrap();
let code = get_string(ctx, "code").expect("argument should exist");
tokio::spawn(async move {
let source = source.lock().await;
source.reply(&format!("{:?}", eval(&source.state.lua, &code).await));
@@ -71,7 +71,7 @@ pub fn register(commands: &mut CommandDispatcher<Mutex<CommandSource>>) {
commands.register(
literal("exec").then(argument("code", string()).executes(|ctx: &Ctx| {
let source = ctx.source.clone();
let code = get_string(ctx, "code").unwrap();
let code = get_string(ctx, "code").expect("argument should exist");
tokio::spawn(async move {
let source = source.lock().await;
source.reply(&format!("{:?}", exec(&source.state.lua, &code).await));