mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-20 16:00:29 +00:00
[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.
This commit is contained in:
parent
84c1eac62a
commit
aeabd0761e
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user