@@ -76,6 +76,9 @@ async def convert(self, ctx: Context[Bot], argument: str) -> int | None:
7676        :param argument: the string with the different time units or a variation of 'inf' for an infinite time span 
7777        :returns: the total amount of time in minutes as an int or None if the time span is infinite 
7878        """ 
79+ 
80+         too_big_number  =  1  <<  31 
81+ 
7982        if  argument .lower () in  ("inf" , "perm" , "permanent" , "-1" , "∞" ):
8083            return  None 
8184        if  (match  :=  re .match (r"^(\d+y)?(\d+m)?(\d+w)?(\d+d)?(\d+H)?(\d+M)?$" , argument )) is  None :
@@ -85,16 +88,20 @@ async def convert(self, ctx: Context[Bot], argument: str) -> int | None:
8588            0  if  (value  :=  match .group (i )) is  None  else  int (value [:- 1 ]) for  i  in  range (1 , 7 )
8689        ]
8790
88-         if  any (unit_value  >=  ( 1   <<   31 )  for  unit_value  in  (years , months , weeks , days , hours , minutes )):
91+         if  any (unit_value  >=  too_big_number  for  unit_value  in  (years , months , weeks , days , hours , minutes )):
8992            raise  BadArgument (t .invalid_duration_inf )
9093
9194        days  +=  years  *  365 
9295        days  +=  months  *  30 
96+ 
97+         if  days  >=  too_big_number :
98+             raise  BadArgument (t .invalid_duration_inf )
99+ 
93100        td  =  timedelta (weeks = weeks , days = days , hours = hours , minutes = minutes )
94101        duration  =  int (td .total_seconds () /  60 )
95102
96103        if  duration  <=  0 :
97104            raise  BadArgument (t .invalid_duration )
98-         if  duration  >=  ( 1   <<   31 ) :
105+         if  duration  >=  too_big_number :
99106            raise  BadArgument (t .invalid_duration_inf )
100107        return  duration 
0 commit comments