more commands. fixed an issue with text only commands
This commit is contained in:
@ -38,10 +38,7 @@ async fn create_webhook(
|
||||
include_bytes!(concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/assets/",
|
||||
env!(
|
||||
"WEBHOOK_AVATAR",
|
||||
"WEBHOOK_AVATAR not provided for compilation"
|
||||
)
|
||||
env!("WEBHOOK_AVATAR", "WEBHOOK_AVATAR not provided for compilation")
|
||||
)) as &[u8],
|
||||
env!("WEBHOOK_AVATAR"),
|
||||
),
|
||||
@ -230,14 +227,7 @@ impl<'a> MultiReminderBuilder<'a> {
|
||||
}
|
||||
|
||||
pub async fn build(mut self) -> (HashSet<ReminderError>, HashSet<ReminderScope>) {
|
||||
let pool = self
|
||||
.ctx
|
||||
.data
|
||||
.read()
|
||||
.await
|
||||
.get::<SQLPool>()
|
||||
.cloned()
|
||||
.unwrap();
|
||||
let pool = self.ctx.data.read().await.get::<SQLPool>().cloned().unwrap();
|
||||
|
||||
let mut errors = HashSet::new();
|
||||
|
||||
@ -296,7 +286,7 @@ impl<'a> MultiReminderBuilder<'a> {
|
||||
Err(ReminderError::InvalidTag)
|
||||
} else {
|
||||
let mut channel_data =
|
||||
ChannelData::from_channel(channel, &pool).await.unwrap();
|
||||
ChannelData::from_channel(&channel, &pool).await.unwrap();
|
||||
|
||||
if channel_data.webhook_id.is_none()
|
||||
|| channel_data.webhook_token.is_none()
|
||||
|
@ -12,12 +12,7 @@ pub struct Content {
|
||||
|
||||
impl Content {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
content: "".to_string(),
|
||||
tts: false,
|
||||
attachment: None,
|
||||
attachment_name: None,
|
||||
}
|
||||
Self { content: "".to_string(), tts: false, attachment: None, attachment_name: None }
|
||||
}
|
||||
|
||||
pub async fn build<S: ToString>(content: S, message: &Message) -> Result<Self, ContentError> {
|
||||
|
@ -42,22 +42,50 @@ pub enum ReminderError {
|
||||
impl ReminderError {
|
||||
pub fn display(&self, is_natural: bool) -> String {
|
||||
match self {
|
||||
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 => "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(),
|
||||
ReminderError::ShortInterval => format!("Please ensure the interval provided is longer than {min_interval} seconds", min_interval = *MIN_INTERVAL),
|
||||
ReminderError::InvalidTag => "Couldn't find a location by your tag. Your tag must be either a channel or a user (not a role)".to_string(),
|
||||
ReminderError::InvalidTime => if is_natural {
|
||||
"Your time failed to process. Please make it as clear as possible, for example `\"16th of july\"` or `\"in 20 minutes\"`".to_string()
|
||||
} else {
|
||||
"Make sure the time you have provided is in the format of [num][s/m/h/d][num][s/m/h/d] etc. or `day/month/year-hour:minute:second`".to_string()
|
||||
},
|
||||
ReminderError::InvalidExpiration => if is_natural {
|
||||
"Your expiration time failed to process. Please make it as clear as possible, for example `\"16th of july\"` or `\"in 20 minutes\"`".to_string()
|
||||
} else {
|
||||
"Make sure the expiration time you have provided is in the format of [num][s/m/h/d][num][s/m/h/d] etc. or `day/month/year-hour:minute:second`".to_string()
|
||||
},
|
||||
ReminderError::DiscordError(s) => format!("A Discord error occurred: **{}**", s)
|
||||
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 => {
|
||||
"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()
|
||||
}
|
||||
ReminderError::ShortInterval => format!(
|
||||
"Please ensure the interval provided is longer than {min_interval} seconds",
|
||||
min_interval = *MIN_INTERVAL
|
||||
),
|
||||
ReminderError::InvalidTag => {
|
||||
"Couldn't find a location by your tag. Your tag must be either a channel or \
|
||||
a user (not a role)"
|
||||
.to_string()
|
||||
}
|
||||
ReminderError::InvalidTime => {
|
||||
if is_natural {
|
||||
"Your time failed to process. Please make it as clear as possible, for example `\"16th of july\"` \
|
||||
or `\"in 20 minutes\"`"
|
||||
.to_string()
|
||||
} else {
|
||||
"Make sure the time you have provided is in the format of [num][s/m/h/d][num][s/m/h/d] etc. or \
|
||||
`day/month/year-hour:minute:second`"
|
||||
.to_string()
|
||||
}
|
||||
}
|
||||
ReminderError::InvalidExpiration => {
|
||||
if is_natural {
|
||||
"Your expiration time failed to process. Please make it as clear as possible, for example `\"16th \
|
||||
of july\"` or `\"in 20 minutes\"`"
|
||||
.to_string()
|
||||
} else {
|
||||
"Make sure the expiration time you have provided is in the format of [num][s/m/h/d][num][s/m/h/d] \
|
||||
etc. or `day/month/year-hour:minute:second`"
|
||||
.to_string()
|
||||
}
|
||||
}
|
||||
ReminderError::DiscordError(s) => format!("A Discord error occurred: **{}**", s),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,9 +10,8 @@ pub fn longhand_displacement(seconds: u64) -> String {
|
||||
|
||||
let mut sections = vec![];
|
||||
|
||||
for (var, name) in [days, hours, minutes, seconds]
|
||||
.iter()
|
||||
.zip(["days", "hours", "minutes", "seconds"].iter())
|
||||
for (var, name) in
|
||||
[days, hours, minutes, seconds].iter().zip(["days", "hours", "minutes", "seconds"].iter())
|
||||
{
|
||||
if *var > 0 {
|
||||
sections.push(format!("{} {}", var, name));
|
||||
@ -26,14 +25,7 @@ pub fn generate_uid() -> String {
|
||||
let mut generator: OsRng = Default::default();
|
||||
|
||||
(0..64)
|
||||
.map(|_| {
|
||||
CHARACTERS
|
||||
.chars()
|
||||
.choose(&mut generator)
|
||||
.unwrap()
|
||||
.to_owned()
|
||||
.to_string()
|
||||
})
|
||||
.map(|_| CHARACTERS.chars().choose(&mut generator).unwrap().to_owned().to_string())
|
||||
.collect::<Vec<String>>()
|
||||
.join("")
|
||||
}
|
||||
|
@ -329,18 +329,14 @@ WHERE
|
||||
self.display_content(),
|
||||
time_display,
|
||||
longhand_displacement(interval as u64),
|
||||
self.set_by
|
||||
.map(|i| format!("<@{}>", i))
|
||||
.unwrap_or_else(|| "unknown".to_string())
|
||||
self.set_by.map(|i| format!("<@{}>", i)).unwrap_or_else(|| "unknown".to_string())
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
"'{}' *occurs next at* **{}** (set by {})",
|
||||
self.display_content(),
|
||||
time_display,
|
||||
self.set_by
|
||||
.map(|i| format!("<@{}>", i))
|
||||
.unwrap_or_else(|| "unknown".to_string())
|
||||
self.set_by.map(|i| format!("<@{}>", i)).unwrap_or_else(|| "unknown".to_string())
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -380,9 +376,7 @@ WHERE
|
||||
pub fn signed_action<U: Into<u64>>(&self, member_id: U, action: ReminderAction) -> String {
|
||||
let s_key = hmac::Key::new(
|
||||
hmac::HMAC_SHA256,
|
||||
env::var("SECRET_KEY")
|
||||
.expect("No SECRET_KEY provided")
|
||||
.as_bytes(),
|
||||
env::var("SECRET_KEY").expect("No SECRET_KEY provided").as_bytes(),
|
||||
);
|
||||
|
||||
let mut context = hmac::Context::with_key(&s_key);
|
||||
|
Reference in New Issue
Block a user