bot
bot copied to clipboard
Fixes infraction display duration off-by-one discrepancy
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_appliedtime field for infractions. - Adds refactors for the
last_appliedmodel 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.

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

Related Fixes and improvements
- The
bancommand help message did not accurately reflect its ability to accept expiry ISO times

- This has been improved as such

Design and API Notes
- Commands for durations have been modified from
Expiryto use a new aliasDurationOrExpiry
Expiry = t.Union[Duration, ISODateTime]
->
DurationOrExpiry = t.Union[DurationDelta, ISODateTime]
The added type, in converters.py, is a union between the types
dateutils.timedeltaanddatetime.datetimerespectively.
- The
post_infractionsmethod 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
timedeltaordatetimemarking the absolute expiry date. Originally theexpires_atparameter only accepted adatetimemarking the expiry date.
async def post_infraction(
...
- expires_at: datetime = None,
+ duration_or_expiry: t.Optional[DurationOrExpiry] = None,
...
) -> t.Optional[dict]: