aboutsummaryrefslogtreecommitdiffstats
path: root/bot/bot.py
diff options
context:
space:
mode:
authorGravatar RohanRadia <[email protected]>2019-10-02 20:58:00 +0100
committerGravatar GitHub <[email protected]>2019-10-02 20:58:00 +0100
commit1da22f8a9bd64f13883a4bc8011c9f5069b4dac9 (patch)
treedeaed1b2caf7f650f05e12613cdff5b8a12629c9 /bot/bot.py
parentRemoved unused json (diff)
parentMerge pull request #285 from Numerlor/hacktober-date-channel-fixes (diff)
Merge pull request #3 from python-discord/master
Update
Diffstat (limited to 'bot/bot.py')
-rw-r--r--bot/bot.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/bot/bot.py b/bot/bot.py
index f3b1acbb..2a723021 100644
--- a/bot/bot.py
+++ b/bot/bot.py
@@ -4,14 +4,14 @@ from traceback import format_exc
from typing import List
from aiohttp import AsyncResolver, ClientSession, TCPConnector
-from discord import Embed
+from discord import DiscordException, Embed
from discord.ext import commands
-from bot import constants
+from bot.constants import Channels, Client
log = logging.getLogger(__name__)
-__all__ = ('SeasonalBot',)
+__all__ = ('SeasonalBot', 'bot')
class SeasonalBot(commands.Bot):
@@ -23,9 +23,8 @@ class SeasonalBot(commands.Bot):
connector=TCPConnector(resolver=AsyncResolver(), family=socket.AF_INET)
)
- def load_extensions(self, exts: List[str]):
+ def load_extensions(self, exts: List[str]) -> None:
"""Unload all current extensions, then load the given extensions."""
-
# Unload all cogs
extensions = list(self.extensions.keys())
for extension in extensions:
@@ -41,10 +40,9 @@ class SeasonalBot(commands.Bot):
except Exception as e:
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):
+ async def send_log(self, title: str, details: str = None, *, icon: str = None) -> None:
"""Send an embed message to the devlog channel."""
-
- devlog = self.get_channel(constants.Channels.devlog)
+ devlog = self.get_channel(Channels.devlog)
if not devlog:
log.warning("Log failed to send. Devlog channel not found.")
@@ -58,10 +56,12 @@ class SeasonalBot(commands.Bot):
await devlog.send(embed=embed)
- async def on_command_error(self, context, exception):
+ async def on_command_error(self, context: commands.Context, exception: DiscordException) -> None:
"""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)
+
+
+bot = SeasonalBot(command_prefix=Client.prefix)