diff --git a/src/commands.rs b/src/commands.rs index 6a1c0f7..fa10ccd 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -4,10 +4,12 @@ pub use user_interactions::*; // pub use other::*; pub use voice::*; // pub use command_utils::*; +pub use help::*; pub mod moover; pub mod notice; pub mod user_interactions; // pub mod other; pub mod voice; -// mod command_utils; +// mod command_utils;\ +pub mod help; diff --git a/src/commands/help.rs b/src/commands/help.rs new file mode 100644 index 0000000..e52af16 --- /dev/null +++ b/src/commands/help.rs @@ -0,0 +1,34 @@ +use poise::samples::HelpConfiguration; + +use crate::types::Context; + +type Error = Box; + +/// Show help message +#[poise::command(slash_command, track_edits, category = "Utility")] +pub async fn help( + ctx: Context<'_>, + #[description = "Command to get help for"] + #[rest] + mut command: Option, +) -> 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(()) +} diff --git a/src/commands/voice/general_player.rs b/src/commands/voice/general_player.rs index 3ad9b7b..9f1c43c 100644 --- a/src/commands/voice/general_player.rs +++ b/src/commands/voice/general_player.rs @@ -7,7 +7,7 @@ use crate::commands::voice::voice_utils::autocomplete_channel; use super::connect; -// TODO: search, queue +// For list of supported URLs visit https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md #[poise::command( slash_command, description_localized("en-US", "Plays music from supported URL") diff --git a/src/commands/voice/player_common.rs b/src/commands/voice/player_common.rs index ed92390..2c00877 100644 --- a/src/commands/voice/player_common.rs +++ b/src/commands/voice/player_common.rs @@ -9,10 +9,12 @@ use crate::utils::utilities::get_local_songs; use super::voice_utils::{connect, autocomplete_channel}; -/** - * Common commands that are the same for every implementation - */ +/************************************************************ + * Common commands that are the same for every implementation + ************************************************************/ + +/// Disconnect bot from voice channel #[poise::command( slash_command, description_localized("en-US", "Disconnect from voice channel") @@ -116,7 +118,7 @@ pub async fn play_local(ctx: Context<'_>, Ok(()) } - +/// Sends embed with some info about currently playing source #[poise::command( slash_command, description_localized("en-US", "Display currently playing info") @@ -138,8 +140,6 @@ pub async fn playing(ctx: Context<'_>) -> Result<(), Error> { return Ok(()) }; - // println!("here"); - let embed = { let mutex_hashmap = ctx.data().playing_info.lock().await; let Some(playing_info) = mutex_hashmap.get(&guild_id) else { diff --git a/src/commands/voice/radio/radio_player.rs b/src/commands/voice/radio/radio_player.rs index f33b54a..0f57526 100644 --- a/src/commands/voice/radio/radio_player.rs +++ b/src/commands/voice/radio/radio_player.rs @@ -17,6 +17,7 @@ use crate::commands::voice_types::{NumberOfEntries, PlayingInfoType}; use crate::types::{Context, Error, ContextExt}; use crate::commands::voice::voice_utils::autocomplete_channel; +/// Plays online radio stream #[poise::command( slash_command, description_localized("en-US", "Plays music from URL source"), @@ -26,6 +27,7 @@ pub async fn radio(_ctx: Context<'_>) -> Result<(), Error> { Ok(()) } +/// Play online radio stream directly from URL or autocompleted string #[poise::command( slash_command, description_localized("en-US", "Plays music from URL source") @@ -146,8 +148,9 @@ async fn autocomplete_radio( }; return stations -} +} +/// Search online radios (you can use stream URL from output for /play) #[poise::command( slash_command, description_localized("en-US", "Search for a radio") diff --git a/src/main.rs b/src/main.rs index 417f31c..3b67ffe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -94,7 +94,8 @@ async fn main() -> anyhow::Result<()> { commands::radio::radio(), commands::general_player::play(), commands::player_common::disconnect(), - commands::player_common::playing() + commands::player_common::playing(), + commands::help(), ], prefix_options: poise::PrefixFrameworkOptions { prefix: Some("/".into()),