Skip to content

Commit b14b930

Browse files
authored
Add modmail bans command to list modmail bans (#1286)
Adds a new .modmail bans command to list all currently banned users by modmail.
1 parent 3545c09 commit b14b930

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

techsupport_bot/commands/modmail.py

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

0 commit comments

Comments
 (0)