38 lines
1,021 B
Rust
38 lines
1,021 B
Rust
use poise::samples::HelpConfiguration;
|
|
|
|
use crate::types::Context;
|
|
|
|
type Error = Box<dyn std::error::Error + Send + Sync>;
|
|
|
|
/// Show help message
|
|
#[poise::command(
|
|
slash_command,
|
|
track_edits,
|
|
category = "Help")
|
|
]
|
|
pub async fn help(
|
|
ctx: Context<'_>,
|
|
#[description = "Command to get help for"]
|
|
#[rest]
|
|
mut command: Option<String>,
|
|
) -> Result<(), Error> {
|
|
// This makes it possible to just make `help` a subcommand of any command
|
|
if ctx.invoked_command_name() != "help" {
|
|
command = match command {
|
|
Some(c) => Some(format!("{} {}", ctx.invoked_command_name(), c)),
|
|
None => Some(ctx.invoked_command_name().to_string()),
|
|
};
|
|
}
|
|
let extra_text_at_bottom = "";
|
|
|
|
let config = HelpConfiguration {
|
|
show_subcommands: true,
|
|
show_context_menu_commands: true,
|
|
ephemeral: true,
|
|
extra_text_at_bottom,
|
|
|
|
..Default::default()
|
|
};
|
|
poise::builtins::help(ctx, command.as_deref(), config).await?;
|
|
Ok(())
|
|
}
|