diff options
Diffstat (limited to 'src/commands/today/mod.rs')
| -rw-r--r-- | src/commands/today/mod.rs | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/commands/today/mod.rs b/src/commands/today/mod.rs index c1a02d5..7b5fe8d 100644 --- a/src/commands/today/mod.rs +++ b/src/commands/today/mod.rs @@ -59,29 +59,31 @@ lazy_static! { } #[poise::command(slash_command, prefix_command, guild_only)] -pub async fn today(ctx: PoiseContext<'_>, #[rest] _rest: String) -> anyhow::Result<()> { +pub async fn today(ctx: PoiseContext<'_>, #[rest] _rest: Option<String>) -> anyhow::Result<()> { let today = { #[allow(unused_mut)] let mut result = chrono::Local::now().naive_local(); #[cfg(debug_assertions)] { - let dt = _rest.parse::<chrono::NaiveDateTime>().or_else(|_| { - _rest.parse::<chrono::NaiveDate>().map(|date| { - let time = chrono::NaiveTime::from_hms_opt(12, 0, 0).unwrap(); - date.and_time(time) - }) - }); + if let Some(rest) = _rest { + let dt = rest.parse::<chrono::NaiveDateTime>().or_else(|_| { + rest.parse::<chrono::NaiveDate>().map(|date| { + let time = chrono::NaiveTime::from_hms_opt(12, 0, 0).unwrap(); + date.and_time(time) + }) + }); - match dt { - Ok(dt) => { - debug!("overriding with datetime: {dt}"); - result = dt; - }, - Err(e) => { - debug!("parsing datetime: {e:?}"); - }, - }; + match dt { + Ok(dt) => { + debug!("overriding with datetime: {dt}"); + result = dt; + }, + Err(e) => { + debug!("parsing datetime: {e:?}"); + }, + }; + } } result |
