diff options
| author | 2019-09-16 21:37:49 +0200 | |
|---|---|---|
| committer | 2019-09-16 21:37:49 +0200 | |
| commit | 2b4b0a55f76e1ed63ab6b3f9b6caf76f95c1cccd (patch) | |
| tree | 07309446427c5f5ed4e88a3b29f5d188c6869dfc /bot/cogs/moderation.py | |
| parent | Implement `!otn search`. Closes #408. (diff) | |
| parent | Update discord.py version to 1.2.3 (#433) (diff) | |
Merge branch 'master' into otn-search-command
Diffstat (limited to '')
| -rw-r--r-- | bot/cogs/moderation.py | 15 | 
1 files changed, 9 insertions, 6 deletions
| diff --git a/bot/cogs/moderation.py b/bot/cogs/moderation.py index fb791c933..c631dd69d 100644 --- a/bot/cogs/moderation.py +++ b/bot/cogs/moderation.py @@ -8,7 +8,7 @@ from discord import (      Colour, Embed, Forbidden, Guild, HTTPException, Member, NotFound, Object, User  )  from discord.ext.commands import ( -    BadArgument, BadUnionArgument, Bot, Context, command, group +    BadArgument, BadUnionArgument, Bot, Cog, Context, command, group  )  from bot import constants @@ -28,7 +28,7 @@ INFRACTION_ICONS = {      "Kick": Icons.sign_out,      "Ban": Icons.user_ban  } -RULES_URL = "https://pythondiscord.com/about/rules" +RULES_URL = "https://pythondiscord.com/pages/rules"  APPEALABLE_INFRACTIONS = ("Ban", "Mute") @@ -46,7 +46,7 @@ def proxy_user(user_id: str) -> Object:  UserTypes = Union[Member, User, proxy_user] -class Moderation(Scheduler): +class Moderation(Scheduler, Cog):      """      Server moderation tools.      """ @@ -60,6 +60,7 @@ class Moderation(Scheduler):      def mod_log(self) -> ModLog:          return self.bot.get_cog("ModLog") +    @Cog.listener()      async def on_ready(self):          # Schedule expiration for previous infractions          infractions = await self.bot.api_client.get( @@ -1348,7 +1349,7 @@ class Moderation(Scheduler):          """          # sometimes `user` is a `discord.Object`, so let's make it a proper user. -        user = await self.bot.get_user_info(user.id) +        user = await self.bot.fetch_user(user.id)          try:              await user.send(embed=embed) @@ -1374,13 +1375,15 @@ class Moderation(Scheduler):      # endregion -    async def __error(self, ctx: Context, error) -> None: +    @staticmethod +    async def cog_command_error(ctx: Context, error) -> None:          if isinstance(error, BadUnionArgument):              if User in error.converters:                  await ctx.send(str(error.errors[0]))                  error.handled = True -    async def respect_role_hierarchy(self, ctx: Context, target: UserTypes, infr_type: str) -> bool: +    @staticmethod +    async def respect_role_hierarchy(ctx: Context, target: UserTypes, infr_type: str) -> bool:          """          Check if the highest role of the invoking member is greater than that of the target member.          If this check fails, a warning is sent to the invoking ctx. | 
