38 lines
1.3 KiB
Rust
38 lines
1.3 KiB
Rust
use crate::botv2::init::{Context, Error};
|
|
use poise::samples::HelpConfiguration;
|
|
use tracing::instrument;
|
|
|
|
/// Show help message
|
|
#[poise::command(prefix_command, track_edits, category = "Utility")]
|
|
#[instrument(skip(ctx), level = "info")]
|
|
pub async fn help(
|
|
ctx: Context<'_>,
|
|
#[description = "Command to get help for"]
|
|
#[rest]
|
|
mut command: Option<String>,
|
|
) -> Result<(), Error> {
|
|
tracing::info!(channel = ctx.channel_id().get(), guild = ?ctx.guild_id().unwrap().get(),"Help command called");
|
|
// This makes it possible to just make `help` a subcommand of any command
|
|
// `/fruit help` turns into `/help fruit`
|
|
// `/fruit help apple` turns into `/help fruit apple`
|
|
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 = "\
|
|
Provided by Batleforc with ❤️ and too much ☕";
|
|
|
|
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(())
|
|
}
|