tenebrous-dicebot/src/commands/basic_rolling.rs

29 lines
688 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"
}
fn is_secure(&self) -> bool {
false
}
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
}
}