diff options
| author | 2022-01-08 11:25:07 +0530 | |
|---|---|---|
| committer | 2022-01-08 11:25:07 +0530 | |
| commit | 22ad252db64f351cba32403fd890f281e8d975a0 (patch) | |
| tree | 6f6572ada5fcb302427dcc5657f0fafedd967325 | |
| parent | remove redundant tzinfo check (diff) | |
migrate management.py to arrow
| -rw-r--r-- | bot/exts/moderation/infraction/management.py | 14 | 
1 files changed, 7 insertions, 7 deletions
| diff --git a/bot/exts/moderation/infraction/management.py b/bot/exts/moderation/infraction/management.py index 1db579b89..45a629293 100644 --- a/bot/exts/moderation/infraction/management.py +++ b/bot/exts/moderation/infraction/management.py @@ -1,10 +1,10 @@  import textwrap  import typing as t -from datetime import datetime, timezone -import dateutil.parser +import arrow  import discord  from dateutil.relativedelta import relativedelta +from dateutil.tz import tzutc  from discord.ext import commands  from discord.ext.commands import Context  from discord.utils import escape_markdown @@ -150,7 +150,7 @@ class ModManagement(commands.Cog):              request_data['expires_at'] = None              confirm_messages.append("marked as permanent")          elif duration is not None: -            now_datetime = datetime.now(timezone.utc) +            now_datetime = arrow.utcnow()              if duration < now_datetime:                  await ctx.send(":x: Expiration is in the past.")                  return @@ -376,12 +376,12 @@ class ModManagement(commands.Cog):          if expires_at is None:              duration = "*Permanent*"          else: -            date_from = datetime.fromtimestamp( +            date_from = arrow.Arrow.fromtimestamp(                  float(time.DISCORD_TIMESTAMP_REGEX.match(created).group(1)), -                timezone.utc +                tzutc()              ) -            date_to = dateutil.parser.isoparse(expires_at) -            duration = humanize_delta(relativedelta(date_to, date_from)) +            date_to = arrow.get(expires_at) +            duration = humanize_delta(relativedelta(date_to.datetime, date_from.datetime))          # Format `dm_sent`          if dm_sent is None: | 
