2021-09-02 22:38:12 +00:00
|
|
|
use crate::consts::{MAX_TIME, MIN_INTERVAL};
|
|
|
|
|
|
|
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
|
|
|
pub enum ReminderError {
|
|
|
|
LongTime,
|
|
|
|
LongInterval,
|
|
|
|
PastTime,
|
|
|
|
ShortInterval,
|
|
|
|
InvalidTag,
|
2022-07-29 18:22:15 +00:00
|
|
|
UserBlockedDm,
|
2021-09-02 22:38:12 +00:00
|
|
|
DiscordError(String),
|
|
|
|
}
|
|
|
|
|
2021-09-18 12:40:30 +00:00
|
|
|
impl ToString for ReminderError {
|
|
|
|
fn to_string(&self) -> String {
|
2021-09-02 22:38:12 +00:00
|
|
|
match self {
|
2021-09-10 23:14:23 +00:00
|
|
|
ReminderError::LongTime => {
|
|
|
|
"That time is too far in the future. Please specify a shorter time.".to_string()
|
|
|
|
}
|
|
|
|
ReminderError::LongInterval => format!(
|
|
|
|
"Please ensure the interval specified is less than {max_time} days",
|
|
|
|
max_time = *MAX_TIME / 86_400
|
|
|
|
),
|
|
|
|
ReminderError::PastTime => {
|
2021-09-18 12:40:30 +00:00
|
|
|
"Please ensure the time provided is in the future. If the time should be in the future, please be more specific with the definition.".to_string()
|
2021-09-10 23:14:23 +00:00
|
|
|
}
|
|
|
|
ReminderError::ShortInterval => format!(
|
|
|
|
"Please ensure the interval provided is longer than {min_interval} seconds",
|
|
|
|
min_interval = *MIN_INTERVAL
|
|
|
|
),
|
|
|
|
ReminderError::InvalidTag => {
|
2021-09-18 12:40:30 +00:00
|
|
|
"Couldn't find a location by your tag. Your tag must be either a channel or a user (not a role)".to_string()
|
2021-09-10 23:14:23 +00:00
|
|
|
}
|
2022-07-29 18:22:15 +00:00
|
|
|
ReminderError::UserBlockedDm => {
|
|
|
|
"User has DM reminders disabled".to_string()
|
|
|
|
}
|
2021-09-10 23:14:23 +00:00
|
|
|
ReminderError::DiscordError(s) => format!("A Discord error occurred: **{}**", s),
|
2021-09-02 22:38:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|