From bb1cdbee914a0c8a56b9e1bbe4441edaff9022a4 Mon Sep 17 00:00:00 2001 From: Cycle Five Date: Mon, 17 Jul 2023 21:48:04 -0400 Subject: [PATCH] bug fix --- src/commands/play.rs | 11 +++++++---- src/commands/queue.rs | 9 ++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/commands/play.rs b/src/commands/play.rs index cb9c0b0b..a4502b1a 100644 --- a/src/commands/play.rs +++ b/src/commands/play.rs @@ -3,10 +3,13 @@ use crate::{ errors::{verify, ParrotError}, guild::settings::{GuildSettings, GuildSettingsMap}, handlers::track_end::update_queue_messages, - messaging::message::ParrotMessage, messaging::messages::{ PLAY_QUEUE, PLAY_TOP, SPOTIFY_AUTH_FAILED, TRACK_DURATION, TRACK_TIME_TO_PLAY, }, + messaging::{ + message::ParrotMessage, + messages::{QUEUE_NO_SRC, QUEUE_NO_TITLE}, + }, sources::{ file::{FileRestartable, FileSource}, spotify::{Spotify, SPOTIFY}, @@ -430,14 +433,14 @@ async fn create_queued_embed( let mut embed = CreateEmbed::default(); let metadata = track.metadata().clone(); - embed.thumbnail(&metadata.thumbnail.unwrap()); + embed.thumbnail(&metadata.thumbnail.unwrap_or_default()); embed.field( title, &format!( "[**{}**]({})", - metadata.title.unwrap(), - metadata.source_url.unwrap() + metadata.title.unwrap_or(QUEUE_NO_TITLE.to_string()), + metadata.source_url.unwrap_or(QUEUE_NO_SRC.to_string()) ), false, ); diff --git a/src/commands/queue.rs b/src/commands/queue.rs index 1cd0bed7..409c3e8b 100644 --- a/src/commands/queue.rs +++ b/src/commands/queue.rs @@ -3,8 +3,8 @@ use crate::{ guild::cache::GuildCacheMap, handlers::track_end::ModifyQueueHandler, messaging::messages::{ - QUEUE_EXPIRED, QUEUE_NOTHING_IS_PLAYING, QUEUE_NOW_PLAYING, QUEUE_NO_SONGS, QUEUE_NO_TITLE, - QUEUE_PAGE, QUEUE_PAGE_OF, QUEUE_UP_NEXT, + QUEUE_EXPIRED, QUEUE_NOTHING_IS_PLAYING, QUEUE_NOW_PLAYING, QUEUE_NO_SONGS, QUEUE_NO_SRC, + QUEUE_NO_TITLE, QUEUE_PAGE, QUEUE_PAGE_OF, QUEUE_UP_NEXT, }, utils::get_human_readable_timestamp, }; @@ -152,7 +152,10 @@ pub fn create_queue_embed(tracks: &[TrackHandle], page: usize) -> CreateEmbed { .title .as_ref() .unwrap_or(&String::from(QUEUE_NO_TITLE)), - metadata.source_url.as_ref().unwrap(), + metadata + .source_url + .as_ref() + .unwrap_or(&String::from(QUEUE_NO_SRC)), get_human_readable_timestamp(metadata.duration) ) } else {