From 0b7b1c49ad3f565cac5cdd653cb481b3c6dce7ab Mon Sep 17 00:00:00 2001 From: Vicky Date: Wed, 6 Nov 2024 12:34:37 +0100 Subject: [PATCH] Added skeleton for the handler, and made sure VoteContainer is as future-proof as can be --- src/io.rs | 47 ++++++++++++++--------------------------------- src/modules.rs | 23 +++++++++++++++++++++-- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/io.rs b/src/io.rs index c568376..283f6ad 100644 --- a/src/io.rs +++ b/src/io.rs @@ -42,25 +42,25 @@ type Context<'a> = poise::Context<'a, Data, GenericError>; #[derive(Default)] pub struct VoteContainer { /// The title of the event - title: String, + pub(crate) title: String, /// Description of the event - description: String, + pub(crate) description: String, /// An optional serenity::RoleId to specify the role group concerned by the vote. - group: Option, + pub(crate) group: Option, /// Optional hours describing the specific date of the event - hours: Option, + pub(crate) hours: Option, /// Short name, used in voting titles - short_name: Option, + pub(crate) short_name: Option, /// Auto-Start date of the event (in human-readable format) - start_date: Option, + pub(crate) start_date: Option, /// Days not selected for the vote - non_days: Option, // TODO: What ? + pub(crate) non_days: Option, /// Days selected for the vote - days: String, // TODO: What ? + pub(crate) days: Option, /// Date the event begins - date_begin: String, + pub(crate) date_begin: Option, /// Date the event ends - date_end: String, + pub(crate) date_end: Option, /// An identifier for the vote identifier: VoteTypeIdentifier, } @@ -77,25 +77,6 @@ impl VoteContainer { } } -// /// Default is None -// impl Default for VoteContainer { -// fn default() -> Self { -// Self { -// title: "".to_string(), -// description: "".to_string(), -// group: None, -// hours: None, -// short_name: None, -// start_date: None, -// non_days: None, -// days: "".to_string(), -// date_begin: "".to_string(), -// date_end: "".to_string(), -// identifier: VoteTypeIdentifier::Uninitialised, -// } -// } -// } - /// Identifies the type of the vote being created. /// /// This enum represents different types of votes, such as regular weekly votes, @@ -289,7 +270,7 @@ pub async fn vote_command( let rhubarb = VoteContainer { title, description, - // group, + group, hours, short_name, start_date, @@ -329,7 +310,7 @@ pub async fn short_vote( group, description, hours, - days, + days: Some(days), start_date, ..Default::default() }; @@ -363,8 +344,8 @@ pub async fn long_vote( title, description, start_date, - date_begin, - date_end, + date_begin: Some(date_begin), + date_end: Some(date_end), ..Default::default() }; diff --git a/src/modules.rs b/src/modules.rs index 3f416ba..987e41b 100644 --- a/src/modules.rs +++ b/src/modules.rs @@ -5,11 +5,30 @@ //! Many handler functions //! Every module encompassing a feature -use crate::io::VoteContainer; +use crate::{date::parse_date_list, io::VoteContainer}; /// Handles the vote ? pub fn handler(vc: VoteContainer) { - todo!() + let title = vc.title; + // should be left as is + let description = vc.description; + // should be left as is + let group = vc.group; + // should be left as is + let hours = vc.hours; + // needs to be parsed as start and end hours + let short_name = vc.short_name; + // can be left as is + let start_date = vc.start_date; + // needs to be parsed as single date or set to today's date if None + let non_days = vc.non_days; + // needs to be parsed as a list of days spanning one week after start_date + let days = vc.days; + // needs to be parsed as a list of days spanning one week after start_date + let date_begin = vc.date_begin; + // needs to be parsed as a single date + let date_end = vc.date_end; + // needs to be parsed as a single date } #[cfg(test)]