aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2019-02-27 04:29:54 -0500
committerRapptz <[email protected]>2019-02-27 04:29:54 -0500
commit757584e651dc6f3fa6d5e55ed258c3593db7de26 (patch)
tree9f87fd231cf773e42e3f8999943db5fe7b911725
parentFix Emoji.__hash__ being None. (diff)
downloaddiscord.py-757584e651dc6f3fa6d5e55ed258c3593db7de26.tar.xz
discord.py-757584e651dc6f3fa6d5e55ed258c3593db7de26.zip
[commands] Add support for stacking Cog.listener decorator.
Fix #1926
-rw-r--r--discord/ext/commands/cog.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/discord/ext/commands/cog.py b/discord/ext/commands/cog.py
index 4c4b8eef..217f6388 100644
--- a/discord/ext/commands/cog.py
+++ b/discord/ext/commands/cog.py
@@ -102,7 +102,8 @@ class CogMeta(type):
except AttributeError:
continue
else:
- listeners.append((value.__cog_listener_name__, value.__name__))
+ for name in value.__cog_listener_names__:
+ listeners.append((name, value.__name__))
attrs['__cog_commands__'] = commands # this will be copied in Cog.__new__
attrs['__cog_listeners__'] = tuple(listeners)
@@ -209,7 +210,11 @@ class Cog(metaclass=CogMeta):
if not inspect.iscoroutinefunction(func):
raise TypeError('Listener function must be a coroutine function.')
func.__cog_listener__ = True
- func.__cog_listener_name__ = name or func.__name__
+ to_assign = name or func.__name__
+ try:
+ func.__cog_listener_names__.append(to_assign)
+ except AttributeError:
+ func.__cog_listener_names__ = [to_assign]
return func
return decorator