diff options
| author | Rapptz <[email protected]> | 2019-04-06 19:46:22 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2019-04-06 19:46:22 -0400 |
| commit | 743a5a218ff8d0ee5bb37dca6470d7159a7e30b7 (patch) | |
| tree | f92e4cec362dfd517944adfa18ec60fa2fc98fed /discord/ext/commands/cog.py | |
| parent | Make abc.GuildChannel.overwrites return a dictionary (diff) | |
| download | discord.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.py | 6 |
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__ |