bot icon indicating copy to clipboard operation
bot copied to clipboard

Fixes infraction display duration off-by-one discrepancy

Open ionite34 opened this issue 3 years ago • 0 comments

Closes #2217, Closes #2130

Overview

Fixes the issue of displayed infractions being off from the originally requested duration.

  • Implements new infraction duration calculations using a last_applied time field for infractions.
  • Adds refactors for the last_applied model attribute in the merged PR https://github.com/python-discord/site/pull/751

Test Example

  • Infraction messages now display the correct intended applied time and are no longer off by one or more units.

Durations

  • DMs and most areas where durations are used have also been updated

DM1

Related Fixes and improvements

  • The ban command help message did not accurately reflect its ability to accept expiry ISO times

Ban1

  • This has been improved as such

Ban2

Design and API Notes

  • Commands for durations have been modified from Expiry to use a new alias DurationOrExpiry
Expiry = t.Union[Duration, ISODateTime]
->
DurationOrExpiry = t.Union[DurationDelta, ISODateTime]

The added type, in converters.py, is a union between the types dateutils.timedelta and datetime.datetime respectively.

  • The post_infractions method of _utils.py has an updated parameter name and type. Associated usages have also been updated.
  • The updated name is to reflect that this new parameter may now accept either a timedelta or datetime marking the absolute expiry date. Originally the expires_at parameter only accepted a datetime marking the expiry date.
async def post_infraction(
		...
-     expires_at: datetime = None,
+     duration_or_expiry: t.Optional[DurationOrExpiry] = None,
		...
) -> t.Optional[dict]:

ionite34 avatar Jul 28 '22 08:07 ionite34