aboutsummaryrefslogtreecommitdiff
path: root/discord/ext/commands/cog.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2019-02-27 21:33:52 -0500
committerRapptz <[email protected]>2019-02-27 21:38:55 -0500
commit21a296d53847af3280ba42692081c7836d974b57 (patch)
tree3f83a2f33233303fb0db7af3a6a51e30d49c1158 /discord/ext/commands/cog.py
parentFix typing for Channel.purge's limit kwarg. (diff)
downloaddiscord.py-21a296d53847af3280ba42692081c7836d974b57.tar.xz
discord.py-21a296d53847af3280ba42692081c7836d974b57.zip
[commands] Error out when someone passes plain Cog.listener decorator.
Should make this error easier to catch rather than silent failure.
Diffstat (limited to 'discord/ext/commands/cog.py')
-rw-r--r--discord/ext/commands/cog.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/discord/ext/commands/cog.py b/discord/ext/commands/cog.py
index 217f6388..a51173b9 100644
--- a/discord/ext/commands/cog.py
+++ b/discord/ext/commands/cog.py
@@ -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.')