chore: code cleanup, add command categories

This commit is contained in:
Ladislav Hano 2025-01-27 17:55:26 +01:00
parent 5c804a6946
commit 62abce92f7
8 changed files with 21 additions and 11 deletions

View file

@ -5,7 +5,11 @@ use crate::types::Context;
type Error = Box<dyn std::error::Error + Send + Sync>; type Error = Box<dyn std::error::Error + Send + Sync>;
/// Show help message /// Show help message
#[poise::command(slash_command, track_edits, category = "Utility")] #[poise::command(
slash_command,
track_edits,
category = "Help")
]
pub async fn help( pub async fn help(
ctx: Context<'_>, ctx: Context<'_>,
#[description = "Command to get help for"] #[description = "Command to get help for"]

View file

@ -6,7 +6,8 @@ use crate::types::{Error, Context};
#[poise::command( #[poise::command(
slash_command, slash_command,
description_localized("en-US", "Headpat all your friends!") description_localized("en-US", "Headpat all your friends!"),
category = "Interaction"
)] )]
pub async fn headpat(ctx: Context<'_>, pub async fn headpat(ctx: Context<'_>,
#[description = "Who is the lucky one?"] #[description = "Who is the lucky one?"]

View file

@ -6,7 +6,8 @@ use crate::types::{Error, Context};
#[poise::command( #[poise::command(
slash_command, slash_command,
description_localized("en-US", "Hug all your friends!") description_localized("en-US", "Hug all your friends!"),
category = "Interaction"
)] )]
pub async fn hug(ctx: Context<'_>, pub async fn hug(ctx: Context<'_>,
#[description = "Who is the lucky one?"] #[description = "Who is the lucky one?"]

View file

@ -10,7 +10,8 @@ use super::connect;
// For list of supported URLs visit https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md // For list of supported URLs visit https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md
#[poise::command( #[poise::command(
slash_command, slash_command,
description_localized("en-US", "Plays music from supported URL") description_localized("en-US", "Plays music from supported URL"),
category = "Voice"
)] )]
pub async fn play(ctx: Context<'_>, pub async fn play(ctx: Context<'_>,
#[autocomplete = "autocomplete_channel"] #[autocomplete = "autocomplete_channel"]

View file

@ -17,7 +17,8 @@ use super::voice_utils::{connect, autocomplete_channel};
/// Disconnect bot from voice channel /// Disconnect bot from voice channel
#[poise::command( #[poise::command(
slash_command, slash_command,
description_localized("en-US", "Disconnect from voice channel") description_localized("en-US", "Disconnect from voice channel"),
category = "Voice"
)] )]
pub async fn disconnect( pub async fn disconnect(
ctx: Context<'_> ctx: Context<'_>
@ -66,7 +67,8 @@ async fn autocomplete_song(
#[poise::command( #[poise::command(
slash_command, slash_command,
description_localized("en-US", "Play song from server storage") description_localized("en-US", "Play song from server storage"),
category = "Voice"
)] )]
pub async fn play_local(ctx: Context<'_>, pub async fn play_local(ctx: Context<'_>,
#[autocomplete = "autocomplete_channel"] #[autocomplete = "autocomplete_channel"]
@ -121,7 +123,8 @@ pub async fn play_local(ctx: Context<'_>,
/// Sends embed with some info about currently playing source /// Sends embed with some info about currently playing source
#[poise::command( #[poise::command(
slash_command, slash_command,
description_localized("en-US", "Display currently playing info") description_localized("en-US", "Display currently playing info"),
category = "Voice"
)] )]
pub async fn playing(ctx: Context<'_>) -> Result<(), Error> { pub async fn playing(ctx: Context<'_>) -> Result<(), Error> {
@ -150,8 +153,6 @@ pub async fn playing(ctx: Context<'_>) -> Result<(), Error> {
playing_info.generate_embed().await playing_info.generate_embed().await
}; };
dbg!(&embed);
ctx.send( ctx.send(
CreateReply::default() CreateReply::default()
.embed(embed) .embed(embed)

View file

@ -30,7 +30,8 @@ pub async fn radio(_ctx: Context<'_>) -> Result<(), Error> {
/// Play online radio stream directly from URL or autocompleted string /// Play online radio stream directly from URL or autocompleted string
#[poise::command( #[poise::command(
slash_command, slash_command,
description_localized("en-US", "Plays music from URL source") description_localized("en-US", "Plays music from URL source"),
category = "Voice"
)] )]
pub async fn play(ctx: Context<'_>, pub async fn play(ctx: Context<'_>,
#[autocomplete = "autocomplete_channel"] #[autocomplete = "autocomplete_channel"]
@ -153,7 +154,8 @@ async fn autocomplete_radio(
/// Search online radios (you can use stream URL from output for /play) /// Search online radios (you can use stream URL from output for /play)
#[poise::command( #[poise::command(
slash_command, slash_command,
description_localized("en-US", "Search for a radio") description_localized("en-US", "Search for a radio"),
category = "Voice"
)] )]
pub async fn search(ctx: Context<'_>, pub async fn search(ctx: Context<'_>,
#[description = "Radio station: "] #[description = "Radio station: "]