fixed some messages not sending

This commit is contained in:
jude 2020-10-04 16:17:13 +01:00
parent 836b77d14e
commit db9b0ef2b1
2 changed files with 4 additions and 5 deletions

View File

@ -455,7 +455,7 @@ DELETE FROM reminders WHERE FIND_IN_SET(id, ?)
#[command] #[command]
#[permission_level(Managed)] #[permission_level(Managed)]
async fn timer(ctx: &Context, msg: &Message, args: String) -> CommandResult { async fn timer(ctx: &Context, msg: &Message, args: String) -> CommandResult {
fn time_difference(start_time: NaiveDateTime) -> String { fn time_difference(start_time: NaiveDateTime) -> String {
let unix_time = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs() as i64; let unix_time = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs() as i64;
let now = NaiveDateTime::from_timestamp(unix_time, 0); let now = NaiveDateTime::from_timestamp(unix_time, 0);
@ -736,7 +736,7 @@ async fn remind_command(ctx: &Context, msg: &Message, args: String, command: Rem
Err(ReminderError::NotEnoughArgs) Err(ReminderError::NotEnoughArgs)
}; };
let str_response = response.to_response() let str_response = user_data.response(&pool, &response.to_response()).await
.replacen("{location}", &scope_id.mention(), 1) .replacen("{location}", &scope_id.mention(), 1)
.replacen("{offset}", &time_parser.map(|tp| tp.displacement().ok()).flatten().unwrap_or(-1).to_string(), 1) .replacen("{offset}", &time_parser.map(|tp| tp.displacement().ok()).flatten().unwrap_or(-1).to_string(), 1)
.replacen("{min_interval}", &MIN_INTERVAL.to_string(), 1) .replacen("{min_interval}", &MIN_INTERVAL.to_string(), 1)
@ -837,7 +837,6 @@ async fn natural(ctx: &Context, msg: &Message, args: String) -> CommandResult {
None None
}).flatten(); }).flatten();
} }
} }
if location_ids.len() == 1 { if location_ids.len() == 1 {
@ -853,8 +852,7 @@ async fn natural(ctx: &Context, msg: &Message, args: String) -> CommandResult {
interval, interval,
&content).await; &content).await;
let str_response = user_data.response(&pool, &res.to_response_natural()).await
let str_response = res.to_response_natural()
.replacen("{location}", &location_id.mention(), 1) .replacen("{location}", &location_id.mention(), 1)
.replacen("{offset}", &(timestamp as u64 - since_epoch.as_secs()).to_string(), 1) .replacen("{offset}", &(timestamp as u64 - since_epoch.as_secs()).to_string(), 1)
.replacen("{min_interval}", &MIN_INTERVAL.to_string(), 1) .replacen("{min_interval}", &MIN_INTERVAL.to_string(), 1)

View File

@ -102,6 +102,7 @@ impl TimeParser {
} }
} }
pub fn string_displacement()
fn process_explicit(&self) -> Result<i64, InvalidTime> { fn process_explicit(&self) -> Result<i64, InvalidTime> {
let segments = self.time_string.matches('-').count(); let segments = self.time_string.matches('-').count();