diff options
author | 2023-03-19 15:32:23 +0200 | |
---|---|---|
committer | 2023-03-19 15:32:23 +0200 | |
commit | ea0afec3e936be53fd6f2382de4133445ecb1fa2 (patch) | |
tree | ea3a9a2f146d08da87c0cf8051fc88700d29f661 | |
parent | Mention target user in cap message (diff) |
Add role hierarchy guards for timeouts
Timeouts have similar role hierarchy restrictions to bans.
-rw-r--r-- | bot/exts/moderation/infraction/infractions.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/bot/exts/moderation/infraction/infractions.py b/bot/exts/moderation/infraction/infractions.py index 7400c82f5..d8c997755 100644 --- a/bot/exts/moderation/infraction/infractions.py +++ b/bot/exts/moderation/infraction/infractions.py @@ -408,8 +408,13 @@ class Infractions(InfractionScheduler, commands.Cog): # endregion # region: Base apply functions + @respect_role_hierarchy(member_arg=2) async def apply_timeout(self, ctx: Context, user: Member, reason: t.Optional[str], **kwargs) -> None: """Apply a timeout infraction with kwargs passed to `post_infraction`.""" + if isinstance(user, Member) and user.top_role >= ctx.me.top_role: + await ctx.send(":x: I can't timeout users above or equal to me in the role hierarchy.") + return None + if active := await _utils.get_active_infraction(ctx, user, "timeout", send_msg=False): if active["actor"] != self.bot.user.id: await _utils.send_active_infraction_message(ctx, active) |