From 1b5b863cf35610035f64386fcd2f759920299c06 Mon Sep 17 00:00:00 2001 From: dkay Date: Wed, 30 Apr 2025 19:48:55 -0700 Subject: [PATCH 1/3] Add modmail bans command to list modmail bans --- techsupport_bot/commands/modmail.py | 38 +++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/techsupport_bot/commands/modmail.py b/techsupport_bot/commands/modmail.py index fbb11cf7..fac4e285 100644 --- a/techsupport_bot/commands/modmail.py +++ b/techsupport_bot/commands/modmail.py @@ -1505,3 +1505,41 @@ async def modmail_unban( message=f"{user.mention} was successfully unbanned from creating modmail threads!", channel=ctx.channel, ) + + @auxiliary.with_typing + @commands.check(has_modmail_management_role) + @modmail.command( + name="bans", + description="Lists the users who are banned from using modmail", + ) + async def modmail_list_ban( + self: Self, ctx: commands.Context + ) -> None: + """Lists the users who are banned from using modmail + + Args: + ctx (commands.Context): Context of the command execution + """ + bans = await self.bot.models.ModmailBan.query.gino.all() + if not bans: + embed = auxiliary.generate_basic_embed( + color=discord.Color.green(), + description="There are no modmail bans", + ) + await ctx.channel.send(embed=embed) + return + + embed_description = "" + + for ban in bans: + user: discord.User = await self.bot.fetch_user(ban.user_id) + embed_description += f"{user.mention} - `{user}`\n" + + embed: discord.Embed = discord.Embed( + color=discord.Color.green(), + title="Modmail Bans:", + description=embed_description, + ) + + await ctx.channel.send(embed=embed) + From ff255f4494d45c3e027f44d2a2037dece0a46ff8 Mon Sep 17 00:00:00 2001 From: dkay Date: Wed, 30 Apr 2025 19:53:54 -0700 Subject: [PATCH 2/3] fix tests --- techsupport_bot/commands/modmail.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/techsupport_bot/commands/modmail.py b/techsupport_bot/commands/modmail.py index fac4e285..08f17821 100644 --- a/techsupport_bot/commands/modmail.py +++ b/techsupport_bot/commands/modmail.py @@ -1512,9 +1512,7 @@ async def modmail_unban( name="bans", description="Lists the users who are banned from using modmail", ) - async def modmail_list_ban( - self: Self, ctx: commands.Context - ) -> None: + async def modmail_list_ban(self: Self, ctx: commands.Context) -> None: """Lists the users who are banned from using modmail Args: @@ -1542,4 +1540,3 @@ async def modmail_list_ban( ) await ctx.channel.send(embed=embed) - From 3905bf944c7a742f081db847fca7787ba3b43c40 Mon Sep 17 00:00:00 2001 From: dkay Date: Wed, 30 Apr 2025 19:55:17 -0700 Subject: [PATCH 3/3] rename command function --- techsupport_bot/commands/modmail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/techsupport_bot/commands/modmail.py b/techsupport_bot/commands/modmail.py index 08f17821..cb08bddd 100644 --- a/techsupport_bot/commands/modmail.py +++ b/techsupport_bot/commands/modmail.py @@ -1512,7 +1512,7 @@ async def modmail_unban( name="bans", description="Lists the users who are banned from using modmail", ) - async def modmail_list_ban(self: Self, ctx: commands.Context) -> None: + async def modmail_list_bans(self: Self, ctx: commands.Context) -> None: """Lists the users who are banned from using modmail Args: