Use better error message when failing to get metadata

This commit is contained in:
Alex Page 2024-01-25 20:24:05 -05:00
parent 943f0f2678
commit dc856ea3fd

View file

@ -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"));