diff --git a/Cargo.lock b/Cargo.lock index fa5caf3..b07f3be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -635,12 +635,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "evalexpr" -version = "5.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f92f4c234e4531351f039d03935a5a9b1edc6a7505ffab23e3697bd319d17aa8" - [[package]] name = "fastrand" version = "2.1.0" @@ -1548,20 +1542,6 @@ dependencies = [ "tonic-build", ] -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc", - "rand_pcg", -] - [[package]] name = "rand" version = "0.8.5" @@ -1569,20 +1549,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha 0.3.1", + "rand_chacha", "rand_core 0.6.4", ] -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", -] - [[package]] name = "rand_chacha" version = "0.3.1" @@ -1611,24 +1581,6 @@ dependencies = [ "getrandom 0.2.15", ] -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_pcg" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" -dependencies = [ - "rand_core 0.5.1", -] - [[package]] name = "redox_syscall" version = "0.5.2" @@ -1726,6 +1678,15 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "roll-rs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3784890d00a9e27bf495529d23f962c10aa60df370f7988532f6cbc7608a7fb5" +dependencies = [ + "rand_core 0.5.1", +] + [[package]] name = "ron" version = "0.8.1" @@ -1748,28 +1709,13 @@ dependencies = [ "log", "poise", "raas_types", - "rpg-dice-rust", + "roll-rs", "serde", "structopt", "tokio", "tonic", ] -[[package]] -name = "rpg-dice-rust" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80aceb217a4b4278d0311781bb51209519c913fff317cc67d1b514ba51d21775" -dependencies = [ - "anyhow", - "evalexpr", - "lazy_static", - "rand 0.7.3", - "regex", - "structopt", - "thiserror", -] - [[package]] name = "rust-ini" version = "0.19.0" @@ -2456,7 +2402,7 @@ dependencies = [ "indexmap 1.9.3", "pin-project", "pin-project-lite", - "rand 0.8.5", + "rand", "slab", "tokio", "tokio-util", @@ -2533,7 +2479,7 @@ dependencies = [ "http 1.1.0", "httparse", "log", - "rand 0.8.5", + "rand", "rustls 0.22.4", "rustls-pki-types", "sha1", diff --git a/Cargo.toml b/Cargo.toml index 65ffa29..3e924bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ log = "0.4.22" env_logger = "0.11.3" raas_types = {version = "0.0.9", registry = "jojo-dev"} tonic = "0.11.0" -rpg-dice-rust = "1.1.0" +roll-rs = "0.3.0" chrono = "0.4.38" [dependencies.tokio] diff --git a/src/bot.rs b/src/bot.rs index aa848d7..29aa282 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -1,13 +1,13 @@ use crate::config::BotConfig; use crate::context::Context; use chrono::Utc; -use dicelib::solve_dice_expression; use log::{debug, info}; use poise::serenity_prelude::{CreateAttachment, MessageBuilder}; use poise::CreateReply; use raas_types::raas::bot::roll::{roll_response, Roll, RollCmd}; use raas_types::raas::resp::response::Resp; use raas_types::raas::service::raas_client::RaasClient; +use roll_rs::roll_inline; type Error = Box; type BotContext<'a> = poise::Context<'a, Context, Error>; @@ -17,13 +17,13 @@ async fn roll( ctx: BotContext<'_>, #[description = "Dice String eg 1d20"] roll: String, ) -> Result<(), Error> { - let result = solve_dice_expression(&roll, None)?; + let result = roll_inline(roll.as_str(), true)?; let mut msg = MessageBuilder::new(); - msg.push("Result of: "); - msg.push_mono_line_safe(roll); - msg.push_bold_line_safe(result.to_string()); + msg.push("Result: "); + msg.push_bold_line_safe(result.dice_total.to_string()); + msg.push_mono_line_safe(result.string_result); ctx.reply(msg.build()).await?;