diff --git a/src/main.rs b/src/main.rs index 3e0868a..ac2946c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,18 +36,22 @@ impl EventHandler for Handler { "Betroffene Linien: {}", new.affected_lines .iter() - .fold(String::new(), |acc, a| acc + &format!("{}", a.to_string())) + .fold(String::new(), |acc, a| acc + &a.to_string()) )); let timestamp: Timestamp = new.last_modified.parse().expect("Invalid timestamp!"); let color = new.get_line_color(); new.get_validity_period(); - let embed = if new.from.is_none() || new.to.is_none() { + let embed = if let (Some(from), Some(to)) = (new.from, new.to) { CreateEmbed::new() .title(new.headline) .description(new.detail) .color(Colour::from_rgb(color.0, color.1, color.2)) .timestamp(timestamp) + .fields(vec![ + ("Start", from.to_string(), true), + ("Ende", to.to_string(), true), + ]) .field( "Fahrtrichtungen", format!("{} & {}", &new.dest_1, &new.dest_2), @@ -60,10 +64,6 @@ impl EventHandler for Handler { .description(new.detail) .color(Colour::from_rgb(color.0, color.1, color.2)) .timestamp(timestamp) - .fields(vec![ - ("Start", new.from.unwrap().to_string(), true), - ("Ende", new.to.unwrap().to_string(), true), - ]) .field( "Fahrtrichtungen", format!("{} & {}", new.dest_1, new.dest_2),