2021-01-30 14:17:34 +00:00
|
|
|
use super::{Command, CommandResult, Execution};
|
2020-11-04 20:34:57 +00:00
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
2021-01-30 14:17:34 +00:00
|
|
|
async fn execute(&self, _ctx: &Context<'_>) -> CommandResult {
|
2020-10-31 12:40:44 +00:00
|
|
|
let roll = self.0.roll();
|
|
|
|
let html = format!(
|
|
|
|
"<p><strong>Dice:</strong> {}</p><p><strong>Result</strong>: {}</p>",
|
|
|
|
self.0, roll
|
|
|
|
);
|
2021-01-30 14:17:34 +00:00
|
|
|
|
2021-01-31 14:06:25 +00:00
|
|
|
Execution::new(html)
|
2020-10-31 12:40:44 +00:00
|
|
|
}
|
|
|
|
}
|