diff options
| author | Nathan Perry <np@nathanperry.dev> | 2024-08-16 01:46:17 -0400 |
|---|---|---|
| committer | Nathan Perry <np@nathanperry.dev> | 2024-08-16 01:46:17 -0400 |
| commit | f39b1607b54073646b8ebae8852000706db885ad (patch) | |
| tree | 8033b4460593fb729f6aecc1c7deba84d952f3f0 /src/commands/today/mod.rs | |
| parent | a435a926689b0b597caa1c724a91694f74dec778 (diff) | |
fix required command 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 |
