@@ -76,6 +76,9 @@ async def convert(self, ctx: Context[Bot], argument: str) -> int | None:
76
76
:param argument: the string with the different time units or a variation of 'inf' for an infinite time span
77
77
:returns: the total amount of time in minutes as an int or None if the time span is infinite
78
78
"""
79
+
80
+ too_big_number = 1 << 31
81
+
79
82
if argument .lower () in ("inf" , "perm" , "permanent" , "-1" , "∞" ):
80
83
return None
81
84
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:
85
88
0 if (value := match .group (i )) is None else int (value [:- 1 ]) for i in range (1 , 7 )
86
89
]
87
90
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 )):
89
92
raise BadArgument (t .invalid_duration_inf )
90
93
91
94
days += years * 365
92
95
days += months * 30
96
+
97
+ if days >= too_big_number :
98
+ raise BadArgument (t .invalid_duration_inf )
99
+
93
100
td = timedelta (weeks = weeks , days = days , hours = hours , minutes = minutes )
94
101
duration = int (td .total_seconds () / 60 )
95
102
96
103
if duration <= 0 :
97
104
raise BadArgument (t .invalid_duration )
98
- if duration >= ( 1 << 31 ) :
105
+ if duration >= too_big_number :
99
106
raise BadArgument (t .invalid_duration_inf )
100
107
return duration
0 commit comments