From 53a6588004d506ddfe514d2c9cb4382ad618ac23 Mon Sep 17 00:00:00 2001 From: Atmois Date: Wed, 18 Sep 2024 21:13:29 +0100 Subject: [PATCH] Added silent_action flag for private moderator actions --- tux/cogs/moderation/__init__.py | 5 ++++- tux/cogs/moderation/ban.py | 2 +- tux/cogs/moderation/flag.py | 6 +++--- tux/cogs/moderation/jail.py | 2 +- tux/cogs/moderation/kick.py | 2 +- tux/cogs/moderation/snippetban.py | 10 +++++++++- tux/cogs/moderation/snippetunban.py | 10 +++++++++- tux/cogs/moderation/tempban.py | 2 +- tux/cogs/moderation/timeout.py | 1 + tux/cogs/moderation/unban.py | 10 +++++++++- tux/cogs/moderation/unflag.py | 10 +++++++++- tux/cogs/moderation/unjail.py | 10 +++++++++- tux/cogs/moderation/untimeout.py | 10 +++++++++- tux/cogs/moderation/warn.py | 10 +++++++++- 14 files changed, 75 insertions(+), 15 deletions(-) diff --git a/tux/cogs/moderation/__init__.py b/tux/cogs/moderation/__init__.py index 327a27a2..4127f0fc 100644 --- a/tux/cogs/moderation/__init__.py +++ b/tux/cogs/moderation/__init__.py @@ -212,6 +212,7 @@ async def handle_case_response( reason: str, user: discord.Member | discord.User, dm_sent: bool, + silent_action: bool, duration: str | None = None, ): moderator = ctx.author @@ -248,5 +249,7 @@ async def handle_case_response( else: embed.description = "DMs are disabled for this user or the silent flag was used." - await self.send_embed(ctx, embed, log_type="mod") + if not silent_action: + await self.send_embed(ctx, embed, log_type="mod") + await ctx.send(embed=embed, delete_after=30, ephemeral=True) diff --git a/tux/cogs/moderation/ban.py b/tux/cogs/moderation/ban.py index 7fefd79b..75322f23 100644 --- a/tux/cogs/moderation/ban.py +++ b/tux/cogs/moderation/ban.py @@ -69,7 +69,7 @@ async def ban( guild_id=ctx.guild.id, ) - await self.handle_case_response(ctx, CaseType.BAN, case.case_number, flags.reason, member, dm_sent) + await self.handle_case_response(ctx, CaseType.BAN, case.case_number, flags.reason, member, dm_sent, False) async def setup(bot: Tux) -> None: diff --git a/tux/cogs/moderation/flag.py b/tux/cogs/moderation/flag.py index 84c04c78..c5024a07 100644 --- a/tux/cogs/moderation/flag.py +++ b/tux/cogs/moderation/flag.py @@ -10,7 +10,7 @@ from . import ModerationCogBase -class Flag(ModerationCogBase): +class Unflag(ModerationCogBase): def __init__(self, bot: Tux) -> None: super().__init__(bot) self.case_controller = CaseController() @@ -61,7 +61,7 @@ async def flag( guild_id=ctx.guild.id, ) - await self.handle_case_response(ctx, CaseType.FLAG, case.case_number, flags.reason, member, False) + await self.handle_case_response(ctx, CaseType.FLAG, case.case_number, flags.reason, member, False, True) async def is_flagged(self, guild_id: int, user_id: int) -> bool: """ @@ -90,4 +90,4 @@ async def is_flagged(self, guild_id: int, user_id: int) -> bool: async def setup(bot: Tux) -> None: - await bot.add_cog(Flag(bot)) + await bot.add_cog(Unflag(bot)) diff --git a/tux/cogs/moderation/jail.py b/tux/cogs/moderation/jail.py index 5a51bcbd..eb834de1 100644 --- a/tux/cogs/moderation/jail.py +++ b/tux/cogs/moderation/jail.py @@ -103,7 +103,7 @@ async def jail( # noqa: PLR0911 return dm_sent = await self.send_dm(ctx, flags.silent, member, flags.reason, "jailed") - await self.handle_case_response(ctx, CaseType.JAIL, case.case_number, flags.reason, member, dm_sent) + await self.handle_case_response(ctx, CaseType.JAIL, case.case_number, flags.reason, member, dm_sent, False) def _get_manageable_roles( self, diff --git a/tux/cogs/moderation/kick.py b/tux/cogs/moderation/kick.py index 737bbeba..500da38f 100644 --- a/tux/cogs/moderation/kick.py +++ b/tux/cogs/moderation/kick.py @@ -73,7 +73,7 @@ async def kick( guild_id=ctx.guild.id, ) - await self.handle_case_response(ctx, CaseType.KICK, case.case_number, flags.reason, member, dm_sent) + await self.handle_case_response(ctx, CaseType.KICK, case.case_number, flags.reason, member, dm_sent, False) async def setup(bot: Tux) -> None: diff --git a/tux/cogs/moderation/snippetban.py b/tux/cogs/moderation/snippetban.py index 80cd3ef8..9d04eddd 100644 --- a/tux/cogs/moderation/snippetban.py +++ b/tux/cogs/moderation/snippetban.py @@ -64,7 +64,15 @@ async def snippet_ban( return dm_sent = await self.send_dm(ctx, flags.silent, member, flags.reason, "snippet banned") - await self.handle_case_response(ctx, CaseType.SNIPPETBAN, case.case_number, flags.reason, member, dm_sent) + await self.handle_case_response( + ctx, + CaseType.SNIPPETBAN, + case.case_number, + flags.reason, + member, + dm_sent, + False, + ) async def is_snippetbanned(self, guild_id: int, user_id: int) -> bool: """ diff --git a/tux/cogs/moderation/snippetunban.py b/tux/cogs/moderation/snippetunban.py index d9fea55f..5ccc0fb8 100644 --- a/tux/cogs/moderation/snippetunban.py +++ b/tux/cogs/moderation/snippetunban.py @@ -64,7 +64,15 @@ async def snippet_unban( return dm_sent = await self.send_dm(ctx, flags.silent, member, flags.reason, "snippet unbanned") - await self.handle_case_response(ctx, CaseType.SNIPPETUNBAN, case.case_number, flags.reason, member, dm_sent) + await self.handle_case_response( + ctx, + CaseType.SNIPPETUNBAN, + case.case_number, + flags.reason, + member, + dm_sent, + False, + ) async def is_snippetbanned(self, guild_id: int, user_id: int) -> bool: """ diff --git a/tux/cogs/moderation/tempban.py b/tux/cogs/moderation/tempban.py index 3033c061..c681eb45 100644 --- a/tux/cogs/moderation/tempban.py +++ b/tux/cogs/moderation/tempban.py @@ -76,7 +76,7 @@ async def tempban( case_tempban_expired=False, ) - await self.handle_case_response(ctx, CaseType.TEMPBAN, case.case_number, flags.reason, member, dm_sent) + await self.handle_case_response(ctx, CaseType.TEMPBAN, case.case_number, flags.reason, member, dm_sent, False) @tasks.loop(hours=1) async def tempban_check(self) -> None: diff --git a/tux/cogs/moderation/timeout.py b/tux/cogs/moderation/timeout.py index e908ada2..16fd92a2 100644 --- a/tux/cogs/moderation/timeout.py +++ b/tux/cogs/moderation/timeout.py @@ -86,6 +86,7 @@ async def timeout( flags.reason, member, dm_sent, + False, flags.duration, ) diff --git a/tux/cogs/moderation/unban.py b/tux/cogs/moderation/unban.py index b6a7b2de..4d5c1d95 100644 --- a/tux/cogs/moderation/unban.py +++ b/tux/cogs/moderation/unban.py @@ -74,7 +74,15 @@ async def unban( case_reason=flags.reason, ) - await self.handle_case_response(ctx, CaseType.UNBAN, case.case_number, flags.reason, user, dm_sent=False) + await self.handle_case_response( + ctx, + CaseType.UNBAN, + case.case_number, + flags.reason, + user, + dm_sent=False, + silent_action=False, + ) async def setup(bot: Tux) -> None: diff --git a/tux/cogs/moderation/unflag.py b/tux/cogs/moderation/unflag.py index 9628a0e0..1aba35d1 100644 --- a/tux/cogs/moderation/unflag.py +++ b/tux/cogs/moderation/unflag.py @@ -61,7 +61,15 @@ async def unflag( guild_id=ctx.guild.id, ) - await self.handle_case_response(ctx, CaseType.UNFLAG, case.case_number, flags.reason, member, False) + await self.handle_case_response( + ctx, + CaseType.UNFLAG, + case.case_number, + flags.reason, + member, + False, + silent_action=True, + ) async def is_flagged(self, guild_id: int, user_id: int) -> bool: """ diff --git a/tux/cogs/moderation/unjail.py b/tux/cogs/moderation/unjail.py index 2c3df2cb..a866f504 100644 --- a/tux/cogs/moderation/unjail.py +++ b/tux/cogs/moderation/unjail.py @@ -88,7 +88,15 @@ async def unjail( dm_sent = await self.send_dm(ctx, flags.silent, member, flags.reason, "unjailed") - await self.handle_case_response(ctx, CaseType.UNJAIL, unjail_case.case_number, flags.reason, member, dm_sent) + await self.handle_case_response( + ctx, + CaseType.UNJAIL, + unjail_case.case_number, + flags.reason, + member, + dm_sent, + silent_action=False, + ) async def setup(bot: Tux) -> None: diff --git a/tux/cogs/moderation/untimeout.py b/tux/cogs/moderation/untimeout.py index 27b3adbe..9b1da072 100644 --- a/tux/cogs/moderation/untimeout.py +++ b/tux/cogs/moderation/untimeout.py @@ -72,7 +72,15 @@ async def untimeout( ) dm_sent = await self.send_dm(ctx, flags.silent, member, flags.reason, "untimed out") - await self.handle_case_response(ctx, CaseType.UNTIMEOUT, case.case_number, flags.reason, member, dm_sent) + await self.handle_case_response( + ctx, + CaseType.UNTIMEOUT, + case.case_number, + flags.reason, + member, + dm_sent, + silent_action=False, + ) async def setup(bot: Tux) -> None: diff --git a/tux/cogs/moderation/warn.py b/tux/cogs/moderation/warn.py index d72ddb7b..2ae14265 100644 --- a/tux/cogs/moderation/warn.py +++ b/tux/cogs/moderation/warn.py @@ -56,7 +56,15 @@ async def warn( ) dm_sent = await self.send_dm(ctx, flags.silent, member, flags.reason, "warn") - await self.handle_case_response(ctx, CaseType.WARN, case.case_number, flags.reason, member, dm_sent) + await self.handle_case_response( + ctx, + CaseType.WARN, + case.case_number, + flags.reason, + member, + dm_sent, + silent_action=False, + ) async def setup(bot: Tux) -> None: