Switched roll-rs for roll commands, much more powerful
parent
fb4e245034
commit
6d45cc3548
|
@ -635,12 +635,6 @@ dependencies = [
|
||||||
"version_check",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "evalexpr"
|
|
||||||
version = "5.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f92f4c234e4531351f039d03935a5a9b1edc6a7505ffab23e3697bd319d17aa8"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fastrand"
|
name = "fastrand"
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
|
@ -1548,20 +1542,6 @@ dependencies = [
|
||||||
"tonic-build",
|
"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]]
|
[[package]]
|
||||||
name = "rand"
|
name = "rand"
|
||||||
version = "0.8.5"
|
version = "0.8.5"
|
||||||
|
@ -1569,20 +1549,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"rand_chacha 0.3.1",
|
"rand_chacha",
|
||||||
"rand_core 0.6.4",
|
"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]]
|
[[package]]
|
||||||
name = "rand_chacha"
|
name = "rand_chacha"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
|
@ -1611,24 +1581,6 @@ dependencies = [
|
||||||
"getrandom 0.2.15",
|
"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]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.5.2"
|
version = "0.5.2"
|
||||||
|
@ -1726,6 +1678,15 @@ dependencies = [
|
||||||
"windows-sys 0.52.0",
|
"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]]
|
[[package]]
|
||||||
name = "ron"
|
name = "ron"
|
||||||
version = "0.8.1"
|
version = "0.8.1"
|
||||||
|
@ -1748,28 +1709,13 @@ dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"poise",
|
"poise",
|
||||||
"raas_types",
|
"raas_types",
|
||||||
"rpg-dice-rust",
|
"roll-rs",
|
||||||
"serde",
|
"serde",
|
||||||
"structopt",
|
"structopt",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tonic",
|
"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]]
|
[[package]]
|
||||||
name = "rust-ini"
|
name = "rust-ini"
|
||||||
version = "0.19.0"
|
version = "0.19.0"
|
||||||
|
@ -2456,7 +2402,7 @@ dependencies = [
|
||||||
"indexmap 1.9.3",
|
"indexmap 1.9.3",
|
||||||
"pin-project",
|
"pin-project",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"rand 0.8.5",
|
"rand",
|
||||||
"slab",
|
"slab",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
|
@ -2533,7 +2479,7 @@ dependencies = [
|
||||||
"http 1.1.0",
|
"http 1.1.0",
|
||||||
"httparse",
|
"httparse",
|
||||||
"log",
|
"log",
|
||||||
"rand 0.8.5",
|
"rand",
|
||||||
"rustls 0.22.4",
|
"rustls 0.22.4",
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
"sha1",
|
"sha1",
|
||||||
|
|
|
@ -13,7 +13,7 @@ log = "0.4.22"
|
||||||
env_logger = "0.11.3"
|
env_logger = "0.11.3"
|
||||||
raas_types = {version = "0.0.9", registry = "jojo-dev"}
|
raas_types = {version = "0.0.9", registry = "jojo-dev"}
|
||||||
tonic = "0.11.0"
|
tonic = "0.11.0"
|
||||||
rpg-dice-rust = "1.1.0"
|
roll-rs = "0.3.0"
|
||||||
chrono = "0.4.38"
|
chrono = "0.4.38"
|
||||||
|
|
||||||
[dependencies.tokio]
|
[dependencies.tokio]
|
||||||
|
|
10
src/bot.rs
10
src/bot.rs
|
@ -1,13 +1,13 @@
|
||||||
use crate::config::BotConfig;
|
use crate::config::BotConfig;
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use dicelib::solve_dice_expression;
|
|
||||||
use log::{debug, info};
|
use log::{debug, info};
|
||||||
use poise::serenity_prelude::{CreateAttachment, MessageBuilder};
|
use poise::serenity_prelude::{CreateAttachment, MessageBuilder};
|
||||||
use poise::CreateReply;
|
use poise::CreateReply;
|
||||||
use raas_types::raas::bot::roll::{roll_response, Roll, RollCmd};
|
use raas_types::raas::bot::roll::{roll_response, Roll, RollCmd};
|
||||||
use raas_types::raas::resp::response::Resp;
|
use raas_types::raas::resp::response::Resp;
|
||||||
use raas_types::raas::service::raas_client::RaasClient;
|
use raas_types::raas::service::raas_client::RaasClient;
|
||||||
|
use roll_rs::roll_inline;
|
||||||
|
|
||||||
type Error = Box<dyn std::error::Error + Send + Sync>;
|
type Error = Box<dyn std::error::Error + Send + Sync>;
|
||||||
type BotContext<'a> = poise::Context<'a, Context, Error>;
|
type BotContext<'a> = poise::Context<'a, Context, Error>;
|
||||||
|
@ -17,13 +17,13 @@ async fn roll(
|
||||||
ctx: BotContext<'_>,
|
ctx: BotContext<'_>,
|
||||||
#[description = "Dice String eg 1d20"] roll: String,
|
#[description = "Dice String eg 1d20"] roll: String,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let result = solve_dice_expression(&roll, None)?;
|
let result = roll_inline(roll.as_str(), true)?;
|
||||||
|
|
||||||
let mut msg = MessageBuilder::new();
|
let mut msg = MessageBuilder::new();
|
||||||
|
|
||||||
msg.push("Result of: ");
|
msg.push("Result: ");
|
||||||
msg.push_mono_line_safe(roll);
|
msg.push_bold_line_safe(result.dice_total.to_string());
|
||||||
msg.push_bold_line_safe(result.to_string());
|
msg.push_mono_line_safe(result.string_result);
|
||||||
|
|
||||||
ctx.reply(msg.build()).await?;
|
ctx.reply(msg.build()).await?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue