Use better error message when failing to get metadata
This commit is contained in:
parent
943f0f2678
commit
dc856ea3fd
1 changed files with 26 additions and 2 deletions
|
@ -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"));
|
||||
|
|
Loading…
Add table
Reference in a new issue