Skip to content

Merge infraction edit commands#457

Merged
sco1 merged 8 commits into
masterfrom
infraction-edit-merge
Sep 27, 2019
Merged

Merge infraction edit commands#457
sco1 merged 8 commits into
masterfrom
infraction-edit-merge

Conversation

@MarkKoz
Copy link
Copy Markdown
Contributor

@MarkKoz MarkKoz commented Sep 26, 2019

Closes #349.

Also made the format of infraction timestamps consistent.

Some things to note:

  • If the duration converter fails, the argument will instead be considered part of a reason. Therefore a typo like !infraction edit 1337 50 (missing a unit for the duration) will make the reason 50 and expiration unchanged.
  • The new reason is no longer displayed in the confirmation message. This is similar to Repeating the reason in the confirmation message for infraction commands is redundant #325.
  • The two old commands are gone. Only infraction edit can be used.
  • Expiration for all infractions can still be edited, even ones for which it doesn't make sense (i.e. notes and warnings, which are meant to always be permanent).
  • Editing the expiration for an expired infraction still wont re-apply the infraction (it will reschedule it but the actual moderation action (mute or ban) will not reoccur).

Discord.py's internals use the __func__ attribute of special methods
(cog_command_error, cog_check, cog_before_invoke, cog_after_invoke).
Therefore the methods must be bound methods rather than static so that
the attribute exists.
Both the duration and the reason can be edited with the new command.

* Remove try-except; the default error handler is already adequate
* Remove the new reason from the confirmation message
* Simplify humanisation of the timestamp in the confirmation message
* Add a converter to support permanent durations
@MarkKoz MarkKoz requested a review from scragly September 26, 2019 01:39
@MarkKoz MarkKoz added a: moderation Related to community moderation functionality: (moderation, defcon, verification) type: enhancement labels Sep 26, 2019
@SebastiaanZ
Copy link
Copy Markdown
Contributor

Some things to note:

* If the duration converter fails, the argument will instead be considered part of a reason. Therefore a typo like `!infraction edit 1337 50` (missing a unit for the duration) will make the reason `50` and expiration unchanged.

* The new reason is no longer displayed in the confirmation message. This is similar to #38 

Your solution looks smart.

I'm debating with myself whether or not I should even add, so take this suggestion with a pinch of salt. Your current code does not give feedback when the duration was not changed. If we look at this from a human factors engineering perspective, this means we also don't get feedback about not having changed the duration when we most need it: When we tried to change duration, but made a mistake in the duration string.

Obviously, the absence of feedback could be seen as feedback itself, but with the above perspective in mind, we now have to rely on human memory for the actor to spot that something that should have been there is not. Since we don't edit the duration of an infraction often, this increases the risk of the actor missing the fact that the duration feedback is absent.

A solution would be to always indicate if the duration field was touched, change or not. This would introduce slightly more noise in the confirmation message, but since we infrequently alter infractions and it would be only a couple of words, I'd say that's not a big problem.

That said, we're not designing a nuclear power plant or oil refinery, so scrutiny up to that point is probably over the top. Feel free to ignore it.

* Expiration for all infractions can _still_ be edited, even ones for which it doesn't make sense (i.e. notes and warnings, which are meant to always be permanent).

We could think of adding more validators to the serializer in the back-end. We already have a couple of them and I already proposed two other ones in python-discord/site#260.

https://github.com/python-discord/site/blob/37d989d0b74a1d0f8b0ee60749c79ea4a55ffba5/pydis_site/apps/api/serializers.py#L109-L121

Copy link
Copy Markdown
Contributor

@SebastiaanZ SebastiaanZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small datetime string thing.

Comment thread bot/cogs/moderation.py Outdated
@MarkKoz
Copy link
Copy Markdown
Contributor Author

MarkKoz commented Sep 26, 2019

Your current code does not give feedback when the duration was not changed.

Not explicitly. But if the "confirmation message" that is sent afterwards does not mention the duration but only the reason, then one can assume the duration did not change. Just want to be clear: are you saying that is not adequate? If that's the case, then sure I can agree to this:

A solution would be to always indicate if the duration field was touched, change or not.

@scragly
Copy link
Copy Markdown
Contributor

scragly commented Sep 26, 2019

Yeah he's saying that in this section:

the absence of feedback could be seen as feedback itself, but with the above perspective in mind, we now have to rely on human memory for the actor to spot that something that should have been there is not.

A little convoluted to read, but the meaning is there haha.

I agree explicit feedback is best for now.

Comment thread bot/cogs/moderation.py
@MarkKoz
Copy link
Copy Markdown
Contributor Author

MarkKoz commented Sep 26, 2019

I've tested my changes and all is good. 👍

@MarkKoz MarkKoz requested a review from SebastiaanZ September 26, 2019 16:43
The watchchannel ABC defined its own private utility function to
format ISO datetime strings to something more human-readable. I have
removed this private utility function and replaced the calls to it
with calls to the new `format_infraction` utility function defined in
bot.utils.time.

In addition, I've changed the utility function to use `dateutil` to
parse the datetime string, since `dateutil.parser.isoparse` supports
the strings our API generates out of the box. With the built-in
`datetime.datetime.fromisoformat`, we needed to prepare the string by
slicing of the `Z` timezone indicator.
@sco1 sco1 merged commit 23aded5 into master Sep 27, 2019
@sco1 sco1 deleted the infraction-edit-merge branch September 27, 2019 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: moderation Related to community moderation functionality: (moderation, defcon, verification)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Merge !infr edit reason and !infr edit duration into !infr edit

4 participants