diff options
| author | 2019-03-30 10:40:38 -0400 | |
|---|---|---|
| committer | 2019-03-30 10:42:02 -0400 | |
| commit | 095dc1791f147682023edafc59abdc4019074eeb (patch) | |
| tree | 160d7ee160042befbfba778e54507a5eee3bd686 /bot/bot.py | |
| parent | Merge branch 'master' into hotfix (diff) | |
| parent | Merge pull request #146 from python-discord/flake8-docstring (diff) | |
Merge branch 'master' into hotfix
Diffstat (limited to 'bot/bot.py')
| -rw-r--r-- | bot/bot.py | 22 | 
1 files changed, 14 insertions, 8 deletions
| @@ -5,7 +5,7 @@ from typing import List  from aiohttp import AsyncResolver, ClientSession, TCPConnector  from discord import Embed -from discord.ext.commands import Bot +from discord.ext import commands  from bot import constants @@ -14,7 +14,9 @@ log = logging.getLogger(__name__)  __all__ = ('SeasonalBot',) -class SeasonalBot(Bot): +class SeasonalBot(commands.Bot): +    """Base bot instance.""" +      def __init__(self, **kwargs):          super().__init__(**kwargs)          self.http_session = ClientSession( @@ -22,9 +24,7 @@ class SeasonalBot(Bot):          )      def load_extensions(self, exts: List[str]): -        """ -        Unload all current cogs, then load in the ones passed into `cogs` -        """ +        """Unload all current extensions, then load the given extensions."""          # Unload all cogs          extensions = list(self.extensions.keys()) @@ -42,9 +42,7 @@ class SeasonalBot(Bot):                  log.error(f'Failed to load extension {cog}: {repr(e)} {format_exc()}')      async def send_log(self, title: str, details: str = None, *, icon: str = None): -        """ -        Send an embed message to the devlog channel -        """ +        """Send an embed message to the devlog channel."""          devlog = self.get_channel(constants.Channels.devlog) @@ -59,3 +57,11 @@ class SeasonalBot(Bot):          embed.set_author(name=title, icon_url=icon)          await devlog.send(embed=embed) + +    async def on_command_error(self, context, exception): +        """Check command errors for UserInputError and reset the cooldown if thrown.""" + +        if isinstance(exception, commands.UserInputError): +            context.command.reset_cooldown(context) +        else: +            await super().on_command_error(context, exception) | 
