Skip to content

Commit

Permalink
Mutes Prevent Overflow Error from very large timedeltas
Browse files Browse the repository at this point in the history
Prevent Mute's converter from allowing timedeltas that would result in a timedelta leading to an OverFlow error.
  • Loading branch information
TrustyJAID committed Apr 18, 2024
1 parent 00e41d3 commit 08a551f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion redbot/cogs/mutes/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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
Expand Down Expand Up @@ -57,6 +57,8 @@ async def convert(self, ctx: commands.Context, argument: str) -> _MuteTime:
)
try:
result["duration"] = duration = timedelta(**time_data)
datetime.now(timezone.utc) + 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.")
Expand Down

0 comments on commit 08a551f

Please sign in to comment.