Added skeleton for the handler, and made sure VoteContainer is as future-proof as can be
This commit is contained in:
parent
5e27a178ce
commit
0b7b1c49ad
47
src/io.rs
47
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<serenity::RoleId>,
|
||||
pub(crate) group: Option<serenity::RoleId>,
|
||||
/// Optional hours describing the specific date of the event
|
||||
hours: Option<String>,
|
||||
pub(crate) hours: Option<String>,
|
||||
/// Short name, used in voting titles
|
||||
short_name: Option<String>,
|
||||
pub(crate) short_name: Option<String>,
|
||||
/// Auto-Start date of the event (in human-readable format)
|
||||
start_date: Option<String>,
|
||||
pub(crate) start_date: Option<String>,
|
||||
/// Days not selected for the vote
|
||||
non_days: Option<String>, // TODO: What ?
|
||||
pub(crate) non_days: Option<String>,
|
||||
/// Days selected for the vote
|
||||
days: String, // TODO: What ?
|
||||
pub(crate) days: Option<String>,
|
||||
/// Date the event begins
|
||||
date_begin: String,
|
||||
pub(crate) date_begin: Option<String>,
|
||||
/// Date the event ends
|
||||
date_end: String,
|
||||
pub(crate) date_end: Option<String>,
|
||||
/// 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()
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
Loading…
Reference in New Issue