aboutsummaryrefslogtreecommitdiff
path: root/discord/ext
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-01-25 05:31:53 -0500
committerRapptz <[email protected]>2017-01-25 05:31:53 -0500
commit234fd5180f3381d6e2a4054c23c99a5b15e7a637 (patch)
tree18eb05b667964955a52d4479ddc066901015123a /discord/ext
parentImplement User.profile coroutine to get a user's profile. (diff)
downloaddiscord.py-234fd5180f3381d6e2a4054c23c99a5b15e7a637.tar.xz
discord.py-234fd5180f3381d6e2a4054c23c99a5b15e7a637.zip
Optimise attribute access when dispatching.
Diffstat (limited to 'discord/ext')
-rw-r--r--discord/ext/commands/bot.py19
1 files changed, 3 insertions, 16 deletions
diff --git a/discord/ext/commands/bot.py b/discord/ext/commands/bot.py
index 17772cc5..589e4a6b 100644
--- a/discord/ext/commands/bot.py
+++ b/discord/ext/commands/bot.py
@@ -164,25 +164,12 @@ class BotBase(GroupMixin):
# internal helpers
- @asyncio.coroutine
- def _run_extra(self, coro, event_name, *args, **kwargs):
- try:
- yield from coro(*args, **kwargs)
- except asyncio.CancelledError:
- pass
- except Exception:
- try:
- yield from self.on_error(event_name, *args, **kwargs)
- except asyncio.CancelledError:
- pass
-
def dispatch(self, event_name, *args, **kwargs):
super().dispatch(event_name, *args, **kwargs)
ev = 'on_' + event_name
- if ev in self.extra_events:
- for event in self.extra_events[ev]:
- coro = self._run_extra(event, event_name, *args, **kwargs)
- discord.compat.create_task(coro, loop=self.loop)
+ for event in self.extra_events.get(ev, []):
+ coro = self._run_event(event, event_name, *args, **kwargs)
+ discord.compat.create_task(coro, loop=self.loop)
@asyncio.coroutine
def close(self):