diff options
| -rw-r--r-- | bot/exts/moderation/infraction/_utils.py | 12 | ||||
| -rw-r--r-- | bot/exts/moderation/infraction/management.py | 2 | 
2 files changed, 8 insertions, 6 deletions
| diff --git a/bot/exts/moderation/infraction/_utils.py b/bot/exts/moderation/infraction/_utils.py index 5f2529c6b..02e3ae1aa 100644 --- a/bot/exts/moderation/infraction/_utils.py +++ b/bot/exts/moderation/infraction/_utils.py @@ -170,13 +170,16 @@ async def send_active_infraction_message(ctx: Context, infraction: Infraction) -  async def notify_infraction(          infraction: Infraction,          user: MemberOrUser, -        reason: t.Optional[str] = None +        reason: t.Optional[str] = None, +        resend: bool = False  ) -> bool:      """      DM a user about their new infraction and return True if the DM is successful.      `reason` can be used to override what is in `infraction`. Otherwise, this data will      be retrieved from `infraction`. + +    If `resend` is True, the DM will include both the duration and remaining time.      """      infr_id = infraction["id"]      infr_type = infraction["type"].replace("_", " ").title() @@ -191,11 +194,10 @@ async def notify_infraction(          expires_at = time.format_relative(expiry)          duration = time.humanize_delta(origin, expiry, max_units=2) -        if infraction["active"]: +        if infraction["active"] and resend:              remaining = time.humanize_delta(expiry, arrow.utcnow(), max_units=2) -            if duration != remaining: -                duration += f" ({remaining} remaining)" -        else: +            duration += f" ({remaining} remaining)" +        elif not infraction["active"]:              expires_at += " (Inactive)"      log.trace(f"Sending {user} a DM about their {infr_type} infraction.") diff --git a/bot/exts/moderation/infraction/management.py b/bot/exts/moderation/infraction/management.py index 6ef382119..090fbcdbd 100644 --- a/bot/exts/moderation/infraction/management.py +++ b/bot/exts/moderation/infraction/management.py @@ -79,7 +79,7 @@ class ModManagement(commands.Cog):          reason = infraction["reason"] or "No reason provided."          reason += "\n\n**This is a re-sent message for a previously applied infraction which may have been edited.**" -        if await _utils.notify_infraction(infraction, member, reason): +        if await _utils.notify_infraction(infraction, member, reason, resend=True):              await ctx.send(f":incoming_envelope: Resent DM for infraction `{id_}`.")          else:              await ctx.send(f"{constants.Emojis.failmail} Failed to resend DM for infraction `{id_}`.") | 
