moover_rust/src/commands/help.rs

39 lines
1,021 B
Rust
Raw Normal View History

2025-01-26 22:47:57 +00:00
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")
]
2025-01-26 22:47:57 +00:00
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(())
}