aboutsummaryrefslogtreecommitdiff
path: root/discord/ext/commands/cog.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2019-04-06 19:46:22 -0400
committerRapptz <[email protected]>2019-04-06 19:46:22 -0400
commit743a5a218ff8d0ee5bb37dca6470d7159a7e30b7 (patch)
treef92e4cec362dfd517944adfa18ec60fa2fc98fed /discord/ext/commands/cog.py
parentMake abc.GuildChannel.overwrites return a dictionary (diff)
downloaddiscord.py-743a5a218ff8d0ee5bb37dca6470d7159a7e30b7.tar.xz
discord.py-743a5a218ff8d0ee5bb37dca6470d7159a7e30b7.zip
[commands] Disallow bot_ or cog_ commands or listeners in cogs.
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 109824ed..6d5be625 100644
--- a/discord/ext/commands/cog.py
+++ b/discord/ext/commands/cog.py
@@ -92,6 +92,7 @@ class CogMeta(type):
commands = {}
listeners = {}
+ no_bot_cog = 'Commands or listeners must not start with cog_ or bot_ (in method {0.__name__}.{1})'
new_cls = super().__new__(cls, name, bases, attrs, **kwargs)
for base in reversed(new_cls.__mro__):
@@ -107,7 +108,8 @@ class CogMeta(type):
if isinstance(value, _BaseCommand):
if is_static_method:
raise TypeError('Command in method {0}.{1!r} must not be staticmethod.'.format(base, elem))
-
+ if elem.startswith(('cog_', 'bot_')):
+ raise TypeError(no_bot_cog.format(base, elem))
commands[elem] = value
elif inspect.iscoroutinefunction(value):
try:
@@ -115,6 +117,8 @@ class CogMeta(type):
except AttributeError:
continue
else:
+ if elem.startswith(('cog_', 'bot_')):
+ raise TypeError(no_bot_cog.format(base, elem))
listeners[elem] = value
new_cls.__cog_commands__ = list(commands.values()) # this will be copied in Cog.__new__