mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Catch overflow errors for mutes time conversion (#5605)
This commit is contained in:
parent
193cb3b035
commit
c8ff3c4cce
@ -5,6 +5,7 @@ from datetime import timedelta
|
|||||||
|
|
||||||
from discord.ext.commands.converter import Converter
|
from discord.ext.commands.converter import Converter
|
||||||
from redbot.core import commands
|
from redbot.core import commands
|
||||||
|
from redbot.core import i18n
|
||||||
|
|
||||||
log = logging.getLogger("red.cogs.mutes")
|
log = logging.getLogger("red.cogs.mutes")
|
||||||
|
|
||||||
@ -26,6 +27,8 @@ TIME_RE_STRING = r"|".join(
|
|||||||
TIME_RE = re.compile(TIME_RE_STRING, re.I)
|
TIME_RE = re.compile(TIME_RE_STRING, re.I)
|
||||||
TIME_SPLIT = re.compile(r"t(?:ime)?=")
|
TIME_SPLIT = re.compile(r"t(?:ime)?=")
|
||||||
|
|
||||||
|
_ = i18n.Translator("Mutes", __file__)
|
||||||
|
|
||||||
|
|
||||||
class MuteTime(Converter):
|
class MuteTime(Converter):
|
||||||
"""
|
"""
|
||||||
@ -50,6 +53,11 @@ class MuteTime(Converter):
|
|||||||
if v:
|
if v:
|
||||||
time_data[k] = int(v)
|
time_data[k] = int(v)
|
||||||
if time_data:
|
if time_data:
|
||||||
result["duration"] = timedelta(**time_data)
|
try:
|
||||||
|
result["duration"] = timedelta(**time_data)
|
||||||
|
except OverflowError:
|
||||||
|
raise commands.BadArgument(
|
||||||
|
_("The time provided is too long; use a more reasonable time.")
|
||||||
|
)
|
||||||
result["reason"] = argument.strip()
|
result["reason"] = argument.strip()
|
||||||
return result
|
return result
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user