mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-21 16:52:31 -05:00
Prevent OverflowError from very large timedeltas in Mutes (#6353)
This commit is contained in:
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
import logging
|
||||
import re
|
||||
from typing import Optional, TypedDict
|
||||
from datetime import timedelta
|
||||
from datetime import timedelta, datetime, timezone
|
||||
from typing_extensions import Annotated
|
||||
|
||||
from discord.ext.commands.converter import Converter
|
||||
@@ -29,6 +29,7 @@ def _edgematch(pattern: re.Pattern[str], argument: str) -> Optional[re.Match[str
|
||||
class _MuteTime(TypedDict, total=False):
|
||||
duration: timedelta
|
||||
reason: str
|
||||
until: datetime
|
||||
|
||||
|
||||
class _MuteTimeConverter(Converter):
|
||||
@@ -57,6 +58,8 @@ class _MuteTimeConverter(Converter):
|
||||
)
|
||||
try:
|
||||
result["duration"] = duration = timedelta(**time_data)
|
||||
result["until"] = ctx.message.created_at + duration
|
||||
# Catch if using the timedelta with the current date will also result in an Overflow error
|
||||
except OverflowError:
|
||||
raise commands.BadArgument(
|
||||
_("The time provided is too long; use a more reasonable time.")
|
||||
|
||||
Reference in New Issue
Block a user