diff --git a/src/commands/music/play.rs b/src/commands/music/play.rs index a7bbbb0..6d4bc1f 100644 --- a/src/commands/music/play.rs +++ b/src/commands/music/play.rs @@ -1,19 +1,11 @@ -use serenity::framework::standard::Args; -use serenity::framework::standard::{macros::command, CommandResult}; - -use reqwest::Client as HttpClient; - -use serenity::client::Context; - -use serenity::prelude::TypeMapKey; - +use serenity::framework::standard::macros::command; +use serenity::framework::standard::{Args, CommandResult}; use serenity::model::prelude::*; - +use serenity::prelude::*; +use reqwest::Client as HttpClient; use songbird::input::YoutubeDl; -use songbird::TrackEvent; use crate::commands::misc::check_msg; -use crate::commands::music::misc::TrackErrorNotifier; pub struct HttpKey; @@ -22,27 +14,9 @@ impl TypeMapKey for HttpKey { } #[command] +#[aliases(p)] #[only_in(guilds)] async fn play(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { - let (guild_id, channel_id) = { - let guild = msg.guild(&ctx.cache).unwrap(); - let channel_id = guild - .voice_states - .get(&msg.author.id) - .and_then(|voice_state| voice_state.channel_id); - - (guild.id, channel_id) - }; - - let connect_to = match channel_id { - Some(channel) => channel, - None => { - check_msg(msg.reply(ctx, "Not in a voice channel").await); - - return Ok(()); - } - }; - let url = match args.single::() { Ok(url) => url, Err(_) => { @@ -58,6 +32,8 @@ async fn play(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { let do_search = !url.starts_with("http"); + let guild_id = msg.guild_id.unwrap(); + let http_client = { let data = ctx.data.read().await; data.get::() @@ -67,30 +43,25 @@ async fn play(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult { let manager = songbird::get(ctx) .await - .expect("Client placed at init") + .expect("Songbird Voice client placed in at initialisation.") .clone(); - if let Ok(handler_lock) = manager.join(guild_id, connect_to).await { - let mut handler = handler_lock.lock().await; - handler.add_global_event(TrackEvent::Error.into(), TrackErrorNotifier); - } - if let Some(handler_lock) = manager.get(guild_id) { let mut handler = handler_lock.lock().await; let src = if do_search { - YoutubeDl::new(http_client, url) + // YoutubeDl::new_search(http_client, url) + YoutubeDl::new_ytdl_like("yt-dlp", http_client, url) } else { YoutubeDl::new(http_client, url) }; - let _ = handler.play_input(src.clone().into()); check_msg(msg.channel_id.say(&ctx.http, "Playing song").await); } else { check_msg( msg.channel_id - .say(&ctx.http, "Not in a voice channel!") + .say(&ctx.http, "Not in a voice channel to play in") .await, ); } diff --git a/src/commands/music/queue.rs b/src/commands/music/queue.rs index 7b58e2d..33b9df5 100644 --- a/src/commands/music/queue.rs +++ b/src/commands/music/queue.rs @@ -3,10 +3,10 @@ use serenity::framework::standard::CommandResult; use serenity::model::prelude::*; use serenity::prelude::*; -use crate::commands::misc::check_msg; +// use crate::commands::misc::check_msg; #[command] #[only_in(guilds)] -async fn queue(ctx: &Context, msg: &Message) -> CommandResult { +async fn queue(_ctx: &Context, _msg: &Message) -> CommandResult { Ok(()) } \ No newline at end of file diff --git a/src/commands/music/skip.rs b/src/commands/music/skip.rs index 0bf5cce..7b01d2c 100644 --- a/src/commands/music/skip.rs +++ b/src/commands/music/skip.rs @@ -3,10 +3,10 @@ use serenity::framework::standard::CommandResult; use serenity::model::prelude::*; use serenity::prelude::*; -use crate::commands::misc::check_msg; +// use crate::commands::misc::check_msg; #[command] #[only_in(guilds)] -async fn skip(ctx: &Context, msg: &Message) -> CommandResult { +async fn skip(_ctx: &Context, _msg: &Message) -> CommandResult { Ok(()) } \ No newline at end of file diff --git a/src/commands/music/stop.rs b/src/commands/music/stop.rs index 31eb114..2375a54 100644 --- a/src/commands/music/stop.rs +++ b/src/commands/music/stop.rs @@ -17,7 +17,7 @@ async fn stop(ctx: &Context, msg: &Message) -> CommandResult { if let Some(handler_lock) = manager.get(guild_id) { let mut handler = handler_lock.lock().await; - let queue = handler.queue(); + let _queue = handler.queue(); if let Err(e) = handler.deafen(false).await { check_msg( diff --git a/src/main.rs b/src/main.rs index b3f1376..8e53c42 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,7 +17,7 @@ use serenity::{ prelude::GatewayIntents, }; -use tracing::{info, instrument}; +use tracing::info; mod commands;