chore: updates and formatting
This commit is contained in:
parent
2f89b9dbb9
commit
72a1fe8af3
10 changed files with 175 additions and 131 deletions
|
@ -11,46 +11,71 @@ impl Embed {
|
|||
let current_time = Local::now().format("%Y-%m-%d @ %H:%M:%S");
|
||||
|
||||
CreateEmbed::new()
|
||||
.title(title)
|
||||
.description(desc)
|
||||
.color(Color::from_rgb(224, 49, 26))
|
||||
.footer(CreateEmbedFooter::new(format!("> {} - {}", current_time, username)))
|
||||
.title(title)
|
||||
.description(desc)
|
||||
.color(Color::from_rgb(224, 49, 26))
|
||||
.footer(CreateEmbedFooter::new(format!(
|
||||
"> {} - {}",
|
||||
current_time, username
|
||||
)))
|
||||
}
|
||||
|
||||
pub fn create_error_respose(username: &str, error_title: &str, error_desc: &str) -> CreateEmbed {
|
||||
pub fn create_error_respose(
|
||||
username: &str,
|
||||
error_title: &str,
|
||||
error_desc: &str,
|
||||
) -> CreateEmbed {
|
||||
let current_time = Local::now().format("%Y-%m-%d @ %H:%M:%S");
|
||||
|
||||
CreateEmbed::new()
|
||||
.author(CreateEmbedAuthor::new("Oops, something went wrong."))
|
||||
.title(error_title)
|
||||
.description(error_desc)
|
||||
.color(Color::from_rgb(224, 49, 26))
|
||||
.footer(CreateEmbedFooter::new(format!("> {} - {}", current_time, username)))
|
||||
.author(CreateEmbedAuthor::new("Oops, something went wrong."))
|
||||
.title(error_title)
|
||||
.description(error_desc)
|
||||
.color(Color::from_rgb(224, 49, 26))
|
||||
.footer(CreateEmbedFooter::new(format!(
|
||||
"> {} - {}",
|
||||
current_time, username
|
||||
)))
|
||||
}
|
||||
|
||||
pub async fn create_yt_playing(mut src: YoutubeDl, username: &str, show_as_author: &str) -> CreateEmbed {
|
||||
let current_time = Local::now().format("%Y-%m-%d @ %H:%M:%S");
|
||||
pub async fn create_yt_playing(
|
||||
mut src: YoutubeDl,
|
||||
username: &str,
|
||||
show_as_author: &str,
|
||||
) -> CreateEmbed {
|
||||
let current_time = Local::now().format("%Y-%m-%d @ %H:%M:%S");
|
||||
|
||||
// Get metadata
|
||||
let metadata = src.aux_metadata().await.expect("Cannot get metadata");
|
||||
let title = metadata.title.unwrap_or("Unknown title".to_string());
|
||||
let artist = metadata.artist.unwrap_or("Unknown artist".to_string());
|
||||
let duration = metadata.duration.unwrap_or(Duration::from_millis(0));
|
||||
let thumbnail = metadata
|
||||
.thumbnail
|
||||
.unwrap_or("https://http.cat/images/403.jpg".to_string());
|
||||
let link = metadata
|
||||
.source_url
|
||||
.unwrap_or("https://piped.moonleay.net/403".to_string());
|
||||
// Get metadata
|
||||
let metadata = src.aux_metadata().await.expect("Cannot get metadata");
|
||||
let title = metadata.title.unwrap_or("Unknown title".to_string());
|
||||
let artist = metadata.artist.unwrap_or("Unknown artist".to_string());
|
||||
let duration = metadata.duration.unwrap_or(Duration::from_millis(0));
|
||||
let thumbnail = metadata
|
||||
.thumbnail
|
||||
.unwrap_or("https://http.cat/images/403.jpg".to_string());
|
||||
let link = metadata
|
||||
.source_url
|
||||
.unwrap_or("https://piped.moonleay.net/403".to_string());
|
||||
|
||||
CreateEmbed::new()
|
||||
.author(CreateEmbedAuthor::new(show_as_author))
|
||||
.title(title)
|
||||
.url(link)
|
||||
.thumbnail(thumbnail)
|
||||
.field("Artist", artist, true)
|
||||
.field("Duration", format!("{}min {}sec", duration.as_secs() / 60, duration.as_secs() % 60), true)
|
||||
.color(Color::from_rgb(81, 224, 26))
|
||||
.footer(CreateEmbedFooter::new(format!("> {} - {}",current_time, username)))
|
||||
CreateEmbed::new()
|
||||
.author(CreateEmbedAuthor::new(show_as_author))
|
||||
.title(title)
|
||||
.url(link)
|
||||
.thumbnail(thumbnail)
|
||||
.field("Artist", artist, true)
|
||||
.field(
|
||||
"Duration",
|
||||
format!(
|
||||
"{}min {}sec",
|
||||
duration.as_secs() / 60,
|
||||
duration.as_secs() % 60
|
||||
),
|
||||
true,
|
||||
)
|
||||
.color(Color::from_rgb(81, 224, 26))
|
||||
.footer(CreateEmbedFooter::new(format!(
|
||||
"> {} - {}",
|
||||
current_time, username
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue