Skip to content

Commit 1b5b863

Browse files
committed
Add modmail bans command to list modmail bans
1 parent 6abdea5 commit 1b5b863

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

techsupport_bot/commands/modmail.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,3 +1505,41 @@ async def modmail_unban(
15051505
message=f"{user.mention} was successfully unbanned from creating modmail threads!",
15061506
channel=ctx.channel,
15071507
)
1508+
1509+
@auxiliary.with_typing
1510+
@commands.check(has_modmail_management_role)
1511+
@modmail.command(
1512+
name="bans",
1513+
description="Lists the users who are banned from using modmail",
1514+
)
1515+
async def modmail_list_ban(
1516+
self: Self, ctx: commands.Context
1517+
) -> None:
1518+
"""Lists the users who are banned from using modmail
1519+
1520+
Args:
1521+
ctx (commands.Context): Context of the command execution
1522+
"""
1523+
bans = await self.bot.models.ModmailBan.query.gino.all()
1524+
if not bans:
1525+
embed = auxiliary.generate_basic_embed(
1526+
color=discord.Color.green(),
1527+
description="There are no modmail bans",
1528+
)
1529+
await ctx.channel.send(embed=embed)
1530+
return
1531+
1532+
embed_description = ""
1533+
1534+
for ban in bans:
1535+
user: discord.User = await self.bot.fetch_user(ban.user_id)
1536+
embed_description += f"{user.mention} - `{user}`\n"
1537+
1538+
embed: discord.Embed = discord.Embed(
1539+
color=discord.Color.green(),
1540+
title="Modmail Bans:",
1541+
description=embed_description,
1542+
)
1543+
1544+
await ctx.channel.send(embed=embed)
1545+

0 commit comments

Comments
 (0)