aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Daniel Brown <[email protected]>2020-05-07 15:58:09 -0500
committerGravatar Daniel Brown <[email protected]>2020-05-07 15:58:09 -0500
commit79791326bbea2fee3ab06e1055dfe1897e050c51 (patch)
treea512ecae00328ec3ff145c3985b483219543d402
parentAddressing Review Changes (diff)
apply_ban() logic refined
- Refined the logic for `apply_ban()` even further to be cleaner. (Thanks, @MarkKoz!) Signed-off-by: Daniel Brown <[email protected]>
-rw-r--r--bot/cogs/moderation/infractions.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/bot/cogs/moderation/infractions.py b/bot/cogs/moderation/infractions.py
index 89f72ade7..19a3176d9 100644
--- a/bot/cogs/moderation/infractions.py
+++ b/bot/cogs/moderation/infractions.py
@@ -236,27 +236,27 @@ class Infractions(InfractionScheduler, commands.Cog):
Will also remove the banned user from the Big Brother watch list if applicable.
"""
# In the case of a permanent ban, we don't need get_active_infractions to tell us if one is active
- send_msg = kwargs.get("expires_at") is None
- active_infraction = await utils.get_active_infraction(ctx, user, "ban", send_msg)
+ is_temporary = kwargs.get("expires_at") is not None
+ active_infraction = await utils.get_active_infraction(ctx, user, "ban", is_temporary)
if active_infraction:
log.trace("Active infractions found.")
- if kwargs.get('expires_at') is None:
- 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, send_msg)
-
- elif active_infraction.get('expires_at') is None:
- 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']}**."
- )
- return
- else:
+ 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.")
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']}**."
+ )
+ return
+
infraction = await utils.post_infraction(ctx, user, "ban", reason, active=True, **kwargs)
if infraction is None:
return