Compare commits
	
		
			1 Commits
		
	
	
		
			jellywx/gu
			...
			discord-ti
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 51d2ac2b92 | 
							
								
								
									
										2
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							@@ -1285,7 +1285,7 @@ dependencies = [
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[[package]]
 | 
					[[package]]
 | 
				
			||||||
name = "reminder_rs"
 | 
					name = "reminder_rs"
 | 
				
			||||||
version = "1.5.0-1"
 | 
					version = "1.5.0-2"
 | 
				
			||||||
dependencies = [
 | 
					dependencies = [
 | 
				
			||||||
 "Inflector",
 | 
					 "Inflector",
 | 
				
			||||||
 "chrono",
 | 
					 "chrono",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
[package]
 | 
					[package]
 | 
				
			||||||
name = "reminder_rs"
 | 
					name = "reminder_rs"
 | 
				
			||||||
version = "1.5.0-1"
 | 
					version = "1.5.0-2"
 | 
				
			||||||
authors = ["jellywx <judesouthworth@pm.me>"]
 | 
					authors = ["jellywx <judesouthworth@pm.me>"]
 | 
				
			||||||
edition = "2018"
 | 
					edition = "2018"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,5 @@
 | 
				
			|||||||
use regex_command_attr::command;
 | 
					use regex_command_attr::command;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use chrono_tz::Tz;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
use serenity::{
 | 
					use serenity::{
 | 
				
			||||||
    cache::Cache,
 | 
					    cache::Cache,
 | 
				
			||||||
    client::Context,
 | 
					    client::Context,
 | 
				
			||||||
@@ -47,20 +45,10 @@ use std::{
 | 
				
			|||||||
    time::{SystemTime, UNIX_EPOCH},
 | 
					    time::{SystemTime, UNIX_EPOCH},
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::models::{CtxGuildData, MeridianType};
 | 
					use crate::models::CtxGuildData;
 | 
				
			||||||
use regex::Captures;
 | 
					use regex::Captures;
 | 
				
			||||||
use serenity::model::channel::Channel;
 | 
					use serenity::model::channel::Channel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fn shorthand_displacement(seconds: u64) -> String {
 | 
					 | 
				
			||||||
    let (days, seconds) = seconds.div_rem(&DAY);
 | 
					 | 
				
			||||||
    let (hours, seconds) = seconds.div_rem(&HOUR);
 | 
					 | 
				
			||||||
    let (minutes, seconds) = seconds.div_rem(&MINUTE);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    let time_repr = format!("{:02}:{:02}:{:02}", hours, minutes, seconds);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    format!("{} days, {}", days, time_repr)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
fn longhand_displacement(seconds: u64) -> String {
 | 
					fn longhand_displacement(seconds: u64) -> String {
 | 
				
			||||||
    let (days, seconds) = seconds.div_rem(&DAY);
 | 
					    let (days, seconds) = seconds.div_rem(&DAY);
 | 
				
			||||||
    let (hours, seconds) = seconds.div_rem(&HOUR);
 | 
					    let (hours, seconds) = seconds.div_rem(&HOUR);
 | 
				
			||||||
@@ -361,27 +349,11 @@ impl LookReminder {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn display(
 | 
					    fn display(&self, flags: &LookFlags, inter: &str) -> String {
 | 
				
			||||||
        &self,
 | 
					 | 
				
			||||||
        flags: &LookFlags,
 | 
					 | 
				
			||||||
        meridian: &MeridianType,
 | 
					 | 
				
			||||||
        timezone: &Tz,
 | 
					 | 
				
			||||||
        inter: &str,
 | 
					 | 
				
			||||||
    ) -> String {
 | 
					 | 
				
			||||||
        let time_display = match flags.time_display {
 | 
					        let time_display = match flags.time_display {
 | 
				
			||||||
            TimeDisplayType::Absolute => timezone
 | 
					            TimeDisplayType::Absolute => format!("<t:{}>", self.time.timestamp()),
 | 
				
			||||||
                .timestamp(self.time.timestamp(), 0)
 | 
					 | 
				
			||||||
                .format(meridian.fmt_str())
 | 
					 | 
				
			||||||
                .to_string(),
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            TimeDisplayType::Relative => {
 | 
					            TimeDisplayType::Relative => format!("<t:{}:R>", self.time.timestamp()),
 | 
				
			||||||
                let now = SystemTime::now()
 | 
					 | 
				
			||||||
                    .duration_since(UNIX_EPOCH)
 | 
					 | 
				
			||||||
                    .unwrap()
 | 
					 | 
				
			||||||
                    .as_secs();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                longhand_displacement((self.time.timestamp() as u64).checked_sub(now).unwrap_or(1))
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if let Some(interval) = self.interval {
 | 
					        if let Some(interval) = self.interval {
 | 
				
			||||||
@@ -409,8 +381,6 @@ async fn look(ctx: &Context, msg: &Message, args: String) {
 | 
				
			|||||||
    let (pool, lm) = get_ctx_data(&ctx).await;
 | 
					    let (pool, lm) = get_ctx_data(&ctx).await;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let language = UserData::language_of(&msg.author, &pool).await;
 | 
					    let language = UserData::language_of(&msg.author, &pool).await;
 | 
				
			||||||
    let timezone = UserData::timezone_of(&msg.author, &pool).await;
 | 
					 | 
				
			||||||
    let meridian = UserData::meridian_of(&msg.author, &pool).await;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let flags = LookFlags::from_string(&args);
 | 
					    let flags = LookFlags::from_string(&args);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -472,7 +442,7 @@ LIMIT
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        let display = reminders
 | 
					        let display = reminders
 | 
				
			||||||
            .iter()
 | 
					            .iter()
 | 
				
			||||||
            .map(|reminder| reminder.display(&flags, &meridian, &timezone, &inter));
 | 
					            .map(|reminder| reminder.display(&flags, &inter));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let _ = msg.channel_id.say_lines(&ctx, display).await;
 | 
					        let _ = msg.channel_id.say_lines(&ctx, display).await;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -581,14 +551,13 @@ WHERE
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    let enumerated_reminders = reminders.iter().enumerate().map(|(count, reminder)| {
 | 
					    let enumerated_reminders = reminders.iter().enumerate().map(|(count, reminder)| {
 | 
				
			||||||
        reminder_ids.push(reminder.id);
 | 
					        reminder_ids.push(reminder.id);
 | 
				
			||||||
        let time = user_data.timezone().timestamp(reminder.time.timestamp(), 0);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        format!(
 | 
					        format!(
 | 
				
			||||||
            "**{}**: '{}' *<#{}>* at {}",
 | 
					            "**{}**: '{}' *<#{}>* at <t:{}>",
 | 
				
			||||||
            count + 1,
 | 
					            count + 1,
 | 
				
			||||||
            reminder.display_content(),
 | 
					            reminder.display_content(),
 | 
				
			||||||
            reminder.channel,
 | 
					            reminder.channel,
 | 
				
			||||||
            time.format(user_data.meridian().fmt_str())
 | 
					            reminder.time.timestamp()
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1230,9 +1199,7 @@ async fn remind_command(ctx: &Context, msg: &Message, args: String, command: Rem
 | 
				
			|||||||
                                    .replace("{location}", &ok_locations[0].mention())
 | 
					                                    .replace("{location}", &ok_locations[0].mention())
 | 
				
			||||||
                                    .replace(
 | 
					                                    .replace(
 | 
				
			||||||
                                        "{offset}",
 | 
					                                        "{offset}",
 | 
				
			||||||
                                        &shorthand_displacement(
 | 
					                                        &format!("<t:{}:R>", time_parser.timestamp().unwrap()),
 | 
				
			||||||
                                            time_parser.displacement().unwrap() as u64,
 | 
					 | 
				
			||||||
                                        ),
 | 
					 | 
				
			||||||
                                    ),
 | 
					                                    ),
 | 
				
			||||||
                                n => lm
 | 
					                                n => lm
 | 
				
			||||||
                                    .get(&language, "remind/success_bulk")
 | 
					                                    .get(&language, "remind/success_bulk")
 | 
				
			||||||
@@ -1247,9 +1214,7 @@ async fn remind_command(ctx: &Context, msg: &Message, args: String, command: Rem
 | 
				
			|||||||
                                    )
 | 
					                                    )
 | 
				
			||||||
                                    .replace(
 | 
					                                    .replace(
 | 
				
			||||||
                                        "{offset}",
 | 
					                                        "{offset}",
 | 
				
			||||||
                                        &shorthand_displacement(
 | 
					                                        &format!("<t:{}:R>", time_parser.timestamp().unwrap()),
 | 
				
			||||||
                                            time_parser.displacement().unwrap() as u64,
 | 
					 | 
				
			||||||
                                        ),
 | 
					 | 
				
			||||||
                                    ),
 | 
					                                    ),
 | 
				
			||||||
                            };
 | 
					                            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1356,11 +1321,6 @@ async fn remind_command(ctx: &Context, msg: &Message, args: String, command: Rem
 | 
				
			|||||||
async fn natural(ctx: &Context, msg: &Message, args: String) {
 | 
					async fn natural(ctx: &Context, msg: &Message, args: String) {
 | 
				
			||||||
    let (pool, lm) = get_ctx_data(&ctx).await;
 | 
					    let (pool, lm) = get_ctx_data(&ctx).await;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let now = SystemTime::now();
 | 
					 | 
				
			||||||
    let since_epoch = now
 | 
					 | 
				
			||||||
        .duration_since(UNIX_EPOCH)
 | 
					 | 
				
			||||||
        .expect("Time calculated as going backwards. Very bad");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    let user_data = UserData::from_user(&msg.author, &ctx, &pool).await.unwrap();
 | 
					    let user_data = UserData::from_user(&msg.author, &ctx, &pool).await.unwrap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    match REGEX_NATURAL_COMMAND_1.captures(&args) {
 | 
					    match REGEX_NATURAL_COMMAND_1.captures(&args) {
 | 
				
			||||||
@@ -1424,8 +1384,6 @@ async fn natural(ctx: &Context, msg: &Message, args: String) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                match content_res {
 | 
					                match content_res {
 | 
				
			||||||
                    Ok(mut content) => {
 | 
					                    Ok(mut content) => {
 | 
				
			||||||
                        let offset = timestamp as u64 - since_epoch.as_secs();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        let mut ok_locations = vec![];
 | 
					                        let mut ok_locations = vec![];
 | 
				
			||||||
                        let mut err_locations = vec![];
 | 
					                        let mut err_locations = vec![];
 | 
				
			||||||
                        let mut err_types = HashSet::new();
 | 
					                        let mut err_types = HashSet::new();
 | 
				
			||||||
@@ -1457,7 +1415,7 @@ async fn natural(ctx: &Context, msg: &Message, args: String) {
 | 
				
			|||||||
                            1 => lm
 | 
					                            1 => lm
 | 
				
			||||||
                                .get(&user_data.language, "remind/success")
 | 
					                                .get(&user_data.language, "remind/success")
 | 
				
			||||||
                                .replace("{location}", &ok_locations[0].mention())
 | 
					                                .replace("{location}", &ok_locations[0].mention())
 | 
				
			||||||
                                .replace("{offset}", &shorthand_displacement(offset)),
 | 
					                                .replace("{offset}", &format!("<t:{}:R>", timestamp)),
 | 
				
			||||||
                            n => lm
 | 
					                            n => lm
 | 
				
			||||||
                                .get(&user_data.language, "remind/success_bulk")
 | 
					                                .get(&user_data.language, "remind/success_bulk")
 | 
				
			||||||
                                .replace("{number}", &n.to_string())
 | 
					                                .replace("{number}", &n.to_string())
 | 
				
			||||||
@@ -1469,7 +1427,7 @@ async fn natural(ctx: &Context, msg: &Message, args: String) {
 | 
				
			|||||||
                                        .collect::<Vec<String>>()
 | 
					                                        .collect::<Vec<String>>()
 | 
				
			||||||
                                        .join(", "),
 | 
					                                        .join(", "),
 | 
				
			||||||
                                )
 | 
					                                )
 | 
				
			||||||
                                .replace("{offset}", &shorthand_displacement(offset)),
 | 
					                                .replace("{offset}", &format!("<t:{}:R>", timestamp)),
 | 
				
			||||||
                        };
 | 
					                        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        let error_part = format!(
 | 
					                        let error_part = format!(
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user