From aeabd0761e083e28d528c74072cc181a1c71dc64 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sun, 7 Apr 2019 22:31:05 -0400 Subject: [PATCH] [commands] Raise TypeError instead of ClientException in some places Certain decorators and functions expect coroutines and raise an exception when this is not met. Change these to raise the appropriate TypeError since they can't actually be handled by the user gracefully anyway. --- discord/ext/commands/bot.py | 18 +++++++++--------- discord/ext/commands/core.py | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/discord/ext/commands/bot.py b/discord/ext/commands/bot.py index 4b9c8e009..356675596 100644 --- a/discord/ext/commands/bot.py +++ b/discord/ext/commands/bot.py @@ -321,11 +321,11 @@ class BotBase(GroupMixin): Raises ------- - :exc:`.ClientException` - The coroutine is not actually a coroutine. + TypeError + The coroutine passed is not actually a coroutine. """ if not asyncio.iscoroutinefunction(coro): - raise discord.ClientException('The pre-invoke hook must be a coroutine.') + raise TypeError('The pre-invoke hook must be a coroutine.') self._before_invoke = coro return coro @@ -354,11 +354,11 @@ class BotBase(GroupMixin): Raises ------- - :exc:`.ClientException` - The coroutine is not actually a coroutine. + TypeError + The coroutine passed is not actually a coroutine. """ if not asyncio.iscoroutinefunction(coro): - raise discord.ClientException('The post-invoke hook must be a coroutine.') + raise TypeError('The post-invoke hook must be a coroutine.') self._after_invoke = coro return coro @@ -390,7 +390,7 @@ class BotBase(GroupMixin): name = func.__name__ if name is None else name if not asyncio.iscoroutinefunction(func): - raise discord.ClientException('Listeners must be coroutines') + raise TypeError('Listeners must be coroutines') if name in self.extra_events: self.extra_events[name].append(func) @@ -443,7 +443,7 @@ class BotBase(GroupMixin): Raises ------- - :exc:`.ClientException` + TypeError The function being listened to is not a coroutine. """ @@ -720,7 +720,7 @@ class BotBase(GroupMixin): def help_command(self, value): if value is not None: if not isinstance(value, HelpCommand): - raise discord.ClientException('help_command must be a subclass of HelpCommand') + raise TypeError('help_command must be a subclass of HelpCommand') if self._help_command is not None: self._help_command._remove_from_bot(self) self._help_command = value diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index 9f4ef00ea..e0357f386 100644 --- a/discord/ext/commands/core.py +++ b/discord/ext/commands/core.py @@ -728,12 +728,12 @@ class Command(_BaseCommand): Raises ------- - discord.ClientException - The coroutine is not actually a coroutine. + TypeError + The coroutine passed is not actually a coroutine. """ if not asyncio.iscoroutinefunction(coro): - raise discord.ClientException('The error handler must be a coroutine.') + raise TypeError('The error handler must be a coroutine.') self.on_error = coro return coro @@ -756,11 +756,11 @@ class Command(_BaseCommand): Raises ------- - :exc:`.ClientException` - The coroutine is not actually a coroutine. + TypeError + The coroutine passed is not actually a coroutine. """ if not asyncio.iscoroutinefunction(coro): - raise discord.ClientException('The pre-invoke hook must be a coroutine.') + raise TypeError('The pre-invoke hook must be a coroutine.') self._before_invoke = coro return coro @@ -783,11 +783,11 @@ class Command(_BaseCommand): Raises ------- - :exc:`.ClientException` - The coroutine is not actually a coroutine. + TypeError + The coroutine passed is not actually a coroutine. """ if not asyncio.iscoroutinefunction(coro): - raise discord.ClientException('The post-invoke hook must be a coroutine.') + raise TypeError('The post-invoke hook must be a coroutine.') self._after_invoke = coro return coro