Skip to content

Commit

Permalink
fix(converter): Broken duration parser
Browse files Browse the repository at this point in the history
  • Loading branch information
null2264 committed Feb 14, 2023
1 parent b432d61 commit 10fcc97
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
30 changes: 18 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# v3.5 (Overhaul an Overhaul?)

## 3.5.2

### Bugfixes
- [**Fixed**] Guild only (slash) commands is registered to DMs
- [**Fixed**] Duration parser stop working
- [**Fixed**] `1 spam` is parsed as 1 seconds

### Improvements
- [**Changed**] Rename some command (only affecting for slash)
Expand All @@ -20,12 +23,14 @@

## 3.5.0 (Overhaul-ception)

**⚠️ DISCLAIMER FOR DEVS: THIS UPDATE (`3.4.x` -> `3.5.x`) CONTAINS BREAKING CHANGES!**

This update is mostly just migration to stable discord.py v2.0 after discord.py development is continued.
Most changes are on the code side, so it shouldn't affect users that much, other than the addition of application commands (or `slash`).

Starting from 3.5 ziBot will only support Python 3.10+
> **Warning**
>
> **THIS UPDATE (`3.4.x` -> `3.5.x`) CONTAINS BREAKING CHANGES!**
>
> This update is mostly just migration to stable discord.py v2.0 after discord.py development is continued.
> Most changes are on the code side, so it shouldn't affect users that much, other than the addition of application commands (or `slash`).
>
> Starting from 3.5 ziBot will only support Python 3.10+
### Bugfixes
- [**Fixed**] Re-enabled meme command, fixed by itself (probably aiohttp's user-agent bug)
Expand Down Expand Up @@ -231,7 +236,6 @@ Starting from 3.5 ziBot will only support Python 3.10+
permissions

# v3.1 (Not So Funny Moderator)
All about moderation, and some fun command changes and addition

## 3.1.0 (April Fools!)

Expand Down Expand Up @@ -264,11 +268,6 @@ All about moderation, and some fun command changes and addition

# v3.0 (Overhaul)

A rewrite and a complete overhaul on the bot, biggest update so far.
This update completely overhauled command system to integrate custom commands
more seemlessly, it's not completely done but old stuff will be added back
slowly in future updates.

## 3.0.5 (Bugfix)

- [**Fixed**] Fix `CCommandNoPerm` not being handled by error handler
Expand Down Expand Up @@ -300,6 +299,13 @@ slowly in future updates.

## 3.0.0 (New Beginning)

> **Note**
>
> A rewrite and a complete overhaul on the bot, biggest update so far.
> This update completely overhauled command system to integrate custom commands
> more seemlessly, it's not completely done but old stuff will be added back
> slowly in future updates.
- [**Rename**] `cogs/` -> `exts/`
- [**New**] Command priority [0: Built-in, 1: Custom]
- [**New**] Use databases to handle SQL (Edit `exts/utils/dbQuery.py` if you're
Expand Down
16 changes: 8 additions & 8 deletions src/main/core/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@

TIME_REGEX = re.compile(
r"""
(?:(?P<years>([\d]+))(?:\ )?(?:years?|y))?
(?:(?P<months>([\d]+))(?:\ )?(?:months?|mo))?
(?:(?P<weeks>([\d]+))(?:\ )?(?:weeks?|w))?
(?:(?P<days>([\d]+))(?:\ )?(?:days?|d))?
(?:(?P<hours>([\d]+))(?:\ )?(?:hours?|h))?
(?:(?P<minutes>([\d]+))(?:\ )?(?:minutes?|mins?|m))?
(?:(?P<seconds>([\d]+))(?:\ )?(?:seconds?|secs?|s))?
(?:(?P<years>([\d]+))((?:\ )?years?|y))?
(?:(?P<months>([\d]+))((?:\ )?months?|mo))?
(?:(?P<weeks>([\d]+))((?:\ )?weeks?|w))?
(?:(?P<days>([\d]+))((?:\ )?days?|d))?
(?:(?P<hours>([\d]+))((?:\ )?hours?|h))?
(?:(?P<minutes>([\d]+))((?:\ )?minutes?|(m(?:in(?:s)?)?)))?
(?:(?P<seconds>([\d]+))((?:\ )?seconds?|(s(?:ec(?:s)?)?)))?
""",
re.VERBOSE | re.IGNORECASE,
)
Expand All @@ -48,7 +48,7 @@ async def convert(self, ctx: Context, argument: str):
now = utcnow()
try:
self.when = now + relativedelta(**kwargs)
self.delta = naturaldelta(self.when, when=now)
self.delta = naturaldelta(self.when - now)
except (ValueError, OverflowError):
raise DefaultError("Invalid time provided")
return self
Expand Down

0 comments on commit 10fcc97

Please sign in to comment.