Skip to content

Commit

Permalink
Added silent_action flag for private moderator actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Atmois committed Sep 18, 2024
1 parent efd1174 commit 53a6588
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 15 deletions.
5 changes: 4 additions & 1 deletion tux/cogs/moderation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion tux/cogs/moderation/ban.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions tux/cogs/moderation/flag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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))
2 changes: 1 addition & 1 deletion tux/cogs/moderation/jail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tux/cogs/moderation/kick.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 9 additions & 1 deletion tux/cogs/moderation/snippetban.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down
10 changes: 9 additions & 1 deletion tux/cogs/moderation/snippetunban.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down
2 changes: 1 addition & 1 deletion tux/cogs/moderation/tempban.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions tux/cogs/moderation/timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ async def timeout(
flags.reason,
member,
dm_sent,
False,
flags.duration,
)

Expand Down
10 changes: 9 additions & 1 deletion tux/cogs/moderation/unban.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 9 additions & 1 deletion tux/cogs/moderation/unflag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down
10 changes: 9 additions & 1 deletion tux/cogs/moderation/unjail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 9 additions & 1 deletion tux/cogs/moderation/untimeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 9 additions & 1 deletion tux/cogs/moderation/warn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 53a6588

Please sign in to comment.