2021-02-07 21:39:21 +00:00
|
|
|
use super::{Command, Execution, ExecutionResult};
|
2020-10-31 12:40:44 +00:00
|
|
|
use crate::context::Context;
|
|
|
|
use crate::help::HelpTopic;
|
|
|
|
use async_trait::async_trait;
|
|
|
|
|
|
|
|
pub struct HelpCommand(pub Option<HelpTopic>);
|
|
|
|
|
|
|
|
#[async_trait]
|
|
|
|
impl Command for HelpCommand {
|
|
|
|
fn name(&self) -> &'static str {
|
|
|
|
"help information"
|
|
|
|
}
|
|
|
|
|
2021-05-21 15:32:08 +00:00
|
|
|
fn is_secure(&self) -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
2021-02-07 21:39:21 +00:00
|
|
|
async fn execute(&self, _ctx: &Context<'_>) -> ExecutionResult {
|
2020-10-31 12:40:44 +00:00
|
|
|
let help = match &self.0 {
|
|
|
|
Some(topic) => topic.message(),
|
|
|
|
_ => "There is no help for this topic",
|
|
|
|
};
|
|
|
|
|
2021-01-31 14:06:25 +00:00
|
|
|
let html = format!("<strong>Help:</strong> {}", help.replace("\n", "<br/>"));
|
2021-02-07 21:39:21 +00:00
|
|
|
Execution::success(html)
|
2020-10-31 12:40:44 +00:00
|
|
|
}
|
|
|
|
}
|