feat: add help command
This commit is contained in:
parent
98c417656b
commit
b98934f79b
6 changed files with 50 additions and 10 deletions
|
@ -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;
|
||||
|
|
34
src/commands/help.rs
Normal file
34
src/commands/help.rs
Normal file
|
@ -0,0 +1,34 @@
|
|||
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 = "Utility")]
|
||||
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(())
|
||||
}
|
|
@ -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")
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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()),
|
||||
|
|
Loading…
Reference in a new issue