diff options
| author | 2020-05-27 07:35:56 +0200 | |
|---|---|---|
| committer | 2020-05-27 07:35:56 +0200 | |
| commit | b51c206e51d0906f326da1e504162920cd2d443d (patch) | |
| tree | 38649a71b04a86be4846b92f18c365e592d7643a | |
| parent | Refactor the in_whitelist deco to a check. (diff) | |
Allow infraction management in modmail category
Diffstat (limited to '')
| -rw-r--r-- | bot/cogs/moderation/management.py | 20 | ||||
| -rw-r--r-- | bot/constants.py | 5 | 
2 files changed, 13 insertions, 12 deletions
| diff --git a/bot/cogs/moderation/management.py b/bot/cogs/moderation/management.py index edfdfd9e2..56f7c390c 100644 --- a/bot/cogs/moderation/management.py +++ b/bot/cogs/moderation/management.py @@ -12,7 +12,7 @@ from bot.bot import Bot  from bot.converters import Expiry, InfractionSearchQuery, allowed_strings, proxy_user  from bot.pagination import LinePaginator  from bot.utils import time -from bot.utils.checks import in_channel_check, with_role_check +from bot.utils.checks import in_whitelist_check, with_role_check  from . import utils  from .infractions import Infractions  from .modlog import ModLog @@ -49,8 +49,8 @@ class ModManagement(commands.Cog):      async def infraction_edit(          self,          ctx: Context, -        infraction_id: t.Union[int, allowed_strings("l", "last", "recent")], -        duration: t.Union[Expiry, allowed_strings("p", "permanent"), None], +        infraction_id: t.Union[int, allowed_strings("l", "last", "recent")],  # noqa: F821 +        duration: t.Union[Expiry, allowed_strings("p", "permanent"), None],   # noqa: F821          *,          reason: str = None      ) -> None: @@ -83,14 +83,14 @@ class ModManagement(commands.Cog):                  "actor__id": ctx.author.id,                  "ordering": "-inserted_at"              } -            infractions = await self.bot.api_client.get(f"bot/infractions", params=params) +            infractions = await self.bot.api_client.get("bot/infractions", params=params)              if infractions:                  old_infraction = infractions[0]                  infraction_id = old_infraction["id"]              else:                  await ctx.send( -                    f":x: Couldn't find most recent infraction; you have never given an infraction." +                    ":x: Couldn't find most recent infraction; you have never given an infraction."                  )                  return          else: @@ -224,7 +224,7 @@ class ModManagement(commands.Cog):      ) -> None:          """Send a paginated embed of infractions for the specified user."""          if not infractions: -            await ctx.send(f":warning: No infractions could be found for that query.") +            await ctx.send(":warning: No infractions could be found for that query.")              return          lines = tuple( @@ -283,10 +283,14 @@ class ModManagement(commands.Cog):      # This cannot be static (must have a __func__ attribute).      def cog_check(self, ctx: Context) -> bool: -        """Only allow moderators from moderator channels to invoke the commands in this cog.""" +        """Only allow moderators inside moderator channels to invoke the commands in this cog."""          checks = [              with_role_check(ctx, *constants.MODERATION_ROLES), -            in_channel_check(ctx, *constants.MODERATION_CHANNELS) +            in_whitelist_check( +                ctx, +                channels=constants.MODERATION_CHANNELS, +                categories=[constants.Categories.modmail], +            )          ]          return all(checks) diff --git a/bot/constants.py b/bot/constants.py index 39de2ee41..2ce5355be 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -612,13 +612,10 @@ PROJECT_ROOT = os.path.abspath(os.path.join(BOT_DIR, os.pardir))  MODERATION_ROLES = Guild.moderation_roles  STAFF_ROLES = Guild.staff_roles -# Roles combinations +# Channel combinations  STAFF_CHANNELS = Guild.staff_channels - -# Default Channel combinations  MODERATION_CHANNELS = Guild.moderation_channels -  # Bot replies  NEGATIVE_REPLIES = [      "Noooooo!!", | 
