tenebrous-dicebot/src/commands/basic_rolling.rs

25 lines
633 B
Rust
Raw Normal View History

use super::{Command, Execution, ExecutionResult};
use crate::basic::dice::ElementExpression;
use crate::basic::roll::Roll;
2020-10-31 12:40:44 +00:00
use crate::context::Context;
use async_trait::async_trait;
pub struct RollCommand(pub ElementExpression);
#[async_trait]
impl Command for RollCommand {
fn name(&self) -> &'static str {
"roll regular dice"
}
async fn execute(&self, _ctx: &Context<'_>) -> ExecutionResult {
2020-10-31 12:40:44 +00:00
let roll = self.0.roll();
let html = format!(
"<strong>Dice:</strong> {}</p><p><strong>Result</strong>: {}",
2020-10-31 12:40:44 +00:00
self.0, roll
);
Execution::success(html)
2020-10-31 12:40:44 +00:00
}
}