From f39b1607b54073646b8ebae8852000706db885ad Mon Sep 17 00:00:00 2001 From: Nathan Perry Date: Fri, 16 Aug 2024 01:46:17 -0400 Subject: fix required command options --- src/commands/today/mod.rs | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'src/commands/today/mod.rs') 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) -> anyhow::Result<()> { let today = { #[allow(unused_mut)] let mut result = chrono::Local::now().naive_local(); #[cfg(debug_assertions)] { - let dt = _rest.parse::().or_else(|_| { - _rest.parse::().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:?}"); - }, - }; + if let Some(rest) = _rest { + let dt = rest.parse::().or_else(|_| { + rest.parse::().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:?}"); + }, + }; + } } result -- cgit v1.3.1