aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Daniel Brown <[email protected]>2020-05-11 12:39:49 -0500
committerGravatar GitHub <[email protected]>2020-05-11 12:39:49 -0500
commitd1af9cda00d18d0fee679964ba177f6a3f7ec196 (patch)
treed3b78e5726003928981f31d4f30a5f223b496e4e
parentapply_ban() logic refined (diff)
Restructure `apply_ban()` logic
Another refactor/cleaning to make the logic clearer and easier to understand. Also cleaned up the trace logs to be shorter and more concise. Thanks, @scragly! Co-authored-by: scragly <[email protected]>
-rw-r--r--bot/cogs/moderation/infractions.py19
1 files changed, 7 insertions, 12 deletions
diff --git a/bot/cogs/moderation/infractions.py b/bot/cogs/moderation/infractions.py
index 19a3176d9..e62a36c43 100644
--- a/bot/cogs/moderation/infractions.py
+++ b/bot/cogs/moderation/infractions.py
@@ -240,23 +240,18 @@ class Infractions(InfractionScheduler, commands.Cog):
active_infraction = await utils.get_active_infraction(ctx, user, "ban", is_temporary)
if active_infraction:
- log.trace("Active infractions found.")
if is_temporary:
- log.trace("Active ban is a temp ban being called by a temp or a perma being called by a temp. Ignore.")
+ log.trace("Tempban ignored as it cannot overwrite an active ban.")
return
- if active_infraction.get('expires_at') is not None:
- log.trace("Active ban is a temporary and being called by a perma. Removing temporary.")
- await self.pardon_infraction(ctx, "ban", user, is_temporary)
-
- else:
- log.trace("Active ban is a perma ban and being called by a perma. Send bounce back message.")
- await ctx.send(
- f":x: According to my records, this user is already permanently banned. "
- f"See infraction **#{active_infraction['id']}**."
- )
+ if active_infraction.get('expires_at') is None:
+ log.trace("Permaban already exists, notify.")
+ await ctx.send(f":x: User is already permanently banned (#{active_infraction['id']}).")
return
+ log.trace("Old tempban is being replaced by new permaban.")
+ await self.pardon_infraction(ctx, "ban", user, is_temporary)
+
infraction = await utils.post_infraction(ctx, user, "ban", reason, active=True, **kwargs)
if infraction is None:
return