mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-22 16:51:59 +00:00
[commands] Error out when someone passes plain Cog.listener decorator.
Should make this error easier to catch rather than silent failure.
This commit is contained in:
parent
8beabcc39a
commit
21a296d538
@ -203,9 +203,13 @@ class Cog(metaclass=CogMeta):
|
||||
Raises
|
||||
--------
|
||||
TypeError
|
||||
The function is not a coroutine function.
|
||||
The function is not a coroutine function or a string was not passed as
|
||||
the name.
|
||||
"""
|
||||
|
||||
if name is not None and not isinstance(name, str):
|
||||
raise TypeError('Cog.listener expected str but received {0.__class__.__name__!r} instead.'.format(name))
|
||||
|
||||
def decorator(func):
|
||||
if not inspect.iscoroutinefunction(func):
|
||||
raise TypeError('Listener function must be a coroutine function.')
|
||||
|
Loading…
x
Reference in New Issue
Block a user