aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar kosayoda <[email protected]>2020-10-08 17:06:36 +0800
committerGravatar kosayoda <[email protected]>2020-10-08 17:06:36 +0800
commit54a0ad23786d50956ac43518bb698f6dcc43a4ad (patch)
tree6bcc75e3136f1e865644ccd68178689d9204f687
parentModify `!superstar` to use `apply_infraction`. (diff)
Resolve logic error with reason override.
The reason override for the user message should be set to the infraction reason *if* the override is None, not if it isn't. The parameter is also renamed to `user_reason` for better clarity.
-rw-r--r--bot/exts/moderation/infraction/_scheduler.py11
-rw-r--r--bot/exts/moderation/infraction/superstarify.py2
2 files changed, 7 insertions, 6 deletions
diff --git a/bot/exts/moderation/infraction/_scheduler.py b/bot/exts/moderation/infraction/_scheduler.py
index b66fdc850..b68921dad 100644
--- a/bot/exts/moderation/infraction/_scheduler.py
+++ b/bot/exts/moderation/infraction/_scheduler.py
@@ -82,14 +82,15 @@ class InfractionScheduler:
infraction: _utils.Infraction,
user: UserSnowflake,
action_coro: t.Optional[t.Awaitable] = None,
- reason_override: t.Optional[str] = None,
+ user_reason: t.Optional[str] = None,
additional_info: t.Optional[str] = None,
) -> bool:
"""
Apply an infraction to the user, log the infraction, and optionally notify the user.
- `reason_override`, if provided, will be sent to the user in place of the infraction reason.
+ `user_reason`, if provided, will be sent to the user in place of the infraction reason.
`additional_info` will be attached to the text field in the mod-log embed.
+
Returns whether or not the infraction succeeded.
"""
infr_type = infraction["type"]
@@ -98,8 +99,8 @@ class InfractionScheduler:
expiry = time.format_infraction_with_duration(infraction["expires_at"])
id_ = infraction['id']
- if reason_override is not None:
- reason_override = reason
+ if user_reason is None:
+ user_reason = reason
if additional_info is not None:
additional_info = ""
@@ -139,7 +140,7 @@ class InfractionScheduler:
log.error(f"Failed to DM {user.id}: could not fetch user (status {e.status})")
else:
# Accordingly display whether the user was successfully notified via DM.
- if await _utils.notify_infraction(user, infr_type, expiry, reason_override, icon):
+ if await _utils.notify_infraction(user, infr_type, expiry, user_reason, icon):
dm_result = ":incoming_envelope: "
dm_log_text = "\nDM: Sent"
diff --git a/bot/exts/moderation/infraction/superstarify.py b/bot/exts/moderation/infraction/superstarify.py
index 3c96f7317..f17214c75 100644
--- a/bot/exts/moderation/infraction/superstarify.py
+++ b/bot/exts/moderation/infraction/superstarify.py
@@ -159,7 +159,7 @@ class Superstarify(InfractionScheduler, Cog):
successful = await self.apply_infraction(
ctx, infraction, member, action(),
- reason_override=superstar_reason,
+ user_reason=superstar_reason,
additional_info=nickname_info
)