@@ -45,15 +45,19 @@ pub async fn invites(ctx: Context<'_>) -> Result<(), Error> {
4545 } ;
4646
4747 // Validate member join date
48- let min_stay_duration = Duration :: days (
48+ let min_stay_duration = Duration :: seconds (
4949 guild_config
5050 . min_member_age
5151 . unwrap_or ( ctx. data ( ) . config . bot . default_min_member_age ) as i64 ,
5252 ) ;
5353
5454 if let Some ( join_date) = member. joined_at {
55- if Utc :: now ( ) - join_date. to_utc ( ) < min_stay_duration {
56- send_error_embed ( ctx, locale, "commands.invites.errors.not_long_enough" ) . await ?;
55+ let join_date_utc = join_date. naive_utc ( ) . and_utc ( ) ;
56+ let joined_time = Utc :: now ( ) - join_date_utc;
57+ if joined_time < min_stay_duration {
58+ let params =
59+ create_not_long_enough_params ( min_stay_duration. num_days ( ) , joined_time. num_days ( ) ) ;
60+ send_not_long_enough_embed ( ctx, locale, params) . await ?;
5761 return Ok ( ( ) ) ;
5862 }
5963 } else {
@@ -173,6 +177,30 @@ async fn send_limit_reached_embed(
173177 Ok ( ( ) )
174178}
175179
180+ async fn send_not_long_enough_embed (
181+ ctx : Context < ' _ > ,
182+ locale : & str ,
183+ params : HashMap < & str , String > ,
184+ ) -> Result < ( ) , Error > {
185+ let embed = CreateEmbed :: default ( )
186+ . title ( t ! ( locale, "commands.invites.errors.not_long_enough.title" ) )
187+ . description ( t ! (
188+ locale,
189+ "commands.invites.errors.not_long_enough.description" ,
190+ params. clone( )
191+ ) )
192+ . color ( 0xFF3333 )
193+ . footer ( CreateEmbedFooter :: new ( t ! (
194+ locale,
195+ "commands.invites.errors.not_long_enough.footer" ,
196+ params. clone( )
197+ ) ) ) ;
198+
199+ ctx. send ( CreateReply :: default ( ) . embed ( embed) . ephemeral ( true ) )
200+ . await ?;
201+ Ok ( ( ) )
202+ }
203+
176204async fn send_success_embed (
177205 ctx : Context < ' _ > ,
178206 locale : & str ,
@@ -224,6 +252,13 @@ fn create_limit_params(role_with_limit: &AllowedRole, used_invites: i64) -> Hash
224252 params
225253}
226254
255+ fn create_not_long_enough_params < ' a > ( days : i64 , remaining : i64 ) -> HashMap < & ' a str , String > {
256+ let mut params = HashMap :: new ( ) ;
257+ params. insert ( "days" , days. to_string ( ) ) ;
258+ params. insert ( "remaining" , remaining. to_string ( ) ) ;
259+ params
260+ }
261+
227262fn create_success_params < ' a > (
228263 role_with_limit : & ' a AllowedRole ,
229264 used_invites : i64 ,
0 commit comments