Compare commits

...

3 commits

9 changed files with 58 additions and 16 deletions

4
.gitignore vendored
View file

@ -12,4 +12,6 @@
mooverdb.db* mooverdb.db*
*.txt *.txt
Cargo.lock

4
Cargo.lock generated
View file

@ -2061,7 +2061,7 @@ dependencies = [
[[package]] [[package]]
name = "moover_rust" name = "moover_rust"
version = "3.3.1" version = "3.4.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
@ -4036,7 +4036,7 @@ dependencies = [
"json", "json",
"regex", "regex",
"reqwest 0.12.12", "reqwest 0.12.12",
"thiserror 1.0.64", "thiserror 2.0.11",
] ]
[[package]] [[package]]

View file

@ -1,6 +1,6 @@
[package] [package]
name = "moover_rust" name = "moover_rust"
version = "3.3.1" version = "3.4.0"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -23,7 +23,7 @@ tenorv2 = { path = "./tenor-v2/tenorv2" }
songbird = { version = "0.4.6", features = ["driver", "builtin-queue"] } songbird = { version = "0.4.6", features = ["driver", "builtin-queue"] }
reqwest = "0.11.27" # songbird depends on ^0.11 reqwest = "0.11.27" # songbird depends on ^0.11
# radiobrowser = "0.6.1" # radiobrowser = "0.6.1"
radiobrowser = { path = "./radiobrowser" } radiobrowser = { path = "./radiobrowser-lib-rust" }
[dependencies.symphonia] [dependencies.symphonia]
version = "0.5.2" version = "0.5.2"

View file

@ -4,10 +4,12 @@ pub use user_interactions::*;
// pub use other::*; // pub use other::*;
pub use voice::*; pub use voice::*;
// pub use command_utils::*; // pub use command_utils::*;
pub use help::*;
pub mod moover; pub mod moover;
pub mod notice; pub mod notice;
pub mod user_interactions; pub mod user_interactions;
// pub mod other; // pub mod other;
pub mod voice; pub mod voice;
// mod command_utils; // mod command_utils;\
pub mod help;

34
src/commands/help.rs Normal file
View 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(())
}

View file

@ -7,7 +7,7 @@ use crate::commands::voice::voice_utils::autocomplete_channel;
use super::connect; 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( #[poise::command(
slash_command, slash_command,
description_localized("en-US", "Plays music from supported URL") description_localized("en-US", "Plays music from supported URL")

View file

@ -9,10 +9,12 @@ use crate::utils::utilities::get_local_songs;
use super::voice_utils::{connect, autocomplete_channel}; 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( #[poise::command(
slash_command, slash_command,
description_localized("en-US", "Disconnect from voice channel") description_localized("en-US", "Disconnect from voice channel")
@ -116,7 +118,7 @@ pub async fn play_local(ctx: Context<'_>,
Ok(()) Ok(())
} }
/// 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")
@ -138,8 +140,6 @@ pub async fn playing(ctx: Context<'_>) -> Result<(), Error> {
return Ok(()) return Ok(())
}; };
// println!("here");
let embed = { let embed = {
let mutex_hashmap = ctx.data().playing_info.lock().await; let mutex_hashmap = ctx.data().playing_info.lock().await;
let Some(playing_info) = mutex_hashmap.get(&guild_id) else { let Some(playing_info) = mutex_hashmap.get(&guild_id) else {

View file

@ -17,6 +17,7 @@ use crate::commands::voice_types::{NumberOfEntries, PlayingInfoType};
use crate::types::{Context, Error, ContextExt}; use crate::types::{Context, Error, ContextExt};
use crate::commands::voice::voice_utils::autocomplete_channel; use crate::commands::voice::voice_utils::autocomplete_channel;
/// Plays online radio stream
#[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"),
@ -26,6 +27,7 @@ pub async fn radio(_ctx: Context<'_>) -> Result<(), Error> {
Ok(()) Ok(())
} }
/// 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")
@ -146,8 +148,9 @@ async fn autocomplete_radio(
}; };
return stations return stations
} }
/// 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")

View file

@ -58,7 +58,7 @@ impl EventHandler for Handler {
} }
async fn ready(&self, ctx: Context, ready: Ready) { async fn ready(&self, ctx: Context, ready: Ready) {
println!("{} v3.3.1 is connected!", ready.user.name); println!("{} v{} is connected!", ready.user.name, option_env!("CARGO_PKG_VERSION").unwrap_or(""));
#[cfg(feature="RELEASE")] { #[cfg(feature="RELEASE")] {
use utils::debug::hello; use utils::debug::hello;
@ -94,7 +94,8 @@ async fn main() -> anyhow::Result<()> {
commands::radio::radio(), commands::radio::radio(),
commands::general_player::play(), commands::general_player::play(),
commands::player_common::disconnect(), commands::player_common::disconnect(),
commands::player_common::playing() commands::player_common::playing(),
commands::help(),
], ],
prefix_options: poise::PrefixFrameworkOptions { prefix_options: poise::PrefixFrameworkOptions {
prefix: Some("/".into()), prefix: Some("/".into()),