diff --git a/src/commands.rs b/src/commands.rs index 57a1c75..1f81380 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -99,7 +99,19 @@ pub async fn play( debug!("Trying to play: {}", url); let mut source: Input = YoutubeDl::new(ctx.data().http_client.clone(), url.clone()).into(); - let metadata = source.aux_metadata().await?; + let metadata = match source.aux_metadata().await { + Ok(metadata) => metadata, + Err(_) => { + response + .edit( + ctx, + CreateReply::default() + .content("I couldn't find that video. Sorry! Maybe check your URL."), + ) + .await?; + return Ok(()); + } + }; debug!("Playing: {:?}", metadata); let title = metadata.title.clone().unwrap_or(String::from("This video")); @@ -181,7 +193,19 @@ pub async fn queue( debug!("Trying to play: {}", url); let mut source: Input = YoutubeDl::new(ctx.data().http_client.clone(), url.clone()).into(); - let metadata = source.aux_metadata().await?; + let metadata = match source.aux_metadata().await { + Ok(metadata) => metadata, + Err(_) => { + response + .edit( + ctx, + CreateReply::default() + .content("I couldn't find that video. Sorry! Maybe check your URL."), + ) + .await?; + return Ok(()); + } + }; debug!("Playing: {:?}", metadata); let title = metadata.title.clone().unwrap_or(String::from("This video"));