diff --git a/discord/ext/commands/cog.py b/discord/ext/commands/cog.py index 3f07dd6b9..4c4b8eefb 100644 --- a/discord/ext/commands/cog.py +++ b/discord/ext/commands/cog.py @@ -115,6 +115,10 @@ class CogMeta(type): def qualified_name(cls): return cls.__cog_name__ +def _cog_special_method(func): + func.__cog_special_method__ = None + return func + class Cog(metaclass=CogMeta): """The base class that all cogs must inherit from. @@ -181,9 +185,7 @@ class Cog(metaclass=CogMeta): @classmethod def _get_overridden_method(cls, method): """Return None if the method is not overridden. Otherwise returns the overridden method.""" - if method.__func__ is getattr(cls, method.__name__): - return None - return method + return getattr(method.__func__, '__cog_special_method__', method) @classmethod def listener(cls, name=None): @@ -211,6 +213,7 @@ class Cog(metaclass=CogMeta): return func return decorator + @_cog_special_method def cog_unload(self): """A special method that is called when the cog gets removed. @@ -221,6 +224,7 @@ class Cog(metaclass=CogMeta): """ pass + @_cog_special_method def bot_check_once(self, ctx): """A special method that registers as a :meth:`.Bot.check_once` check. @@ -230,6 +234,7 @@ class Cog(metaclass=CogMeta): """ return True + @_cog_special_method def bot_check(self, ctx): """A special method that registers as a :meth:`.Bot.check` check. @@ -239,6 +244,7 @@ class Cog(metaclass=CogMeta): """ return True + @_cog_special_method def cog_check(self, ctx): """A special method that registers as a :func:`commands.check` for every command and subcommand in this cog. @@ -248,6 +254,7 @@ class Cog(metaclass=CogMeta): """ return True + @_cog_special_method def cog_command_error(self, ctx, error): """A special method that is called whenever an error is dispatched inside this cog. @@ -266,6 +273,7 @@ class Cog(metaclass=CogMeta): """ pass + @_cog_special_method async def cog_before_invoke(self, ctx): """A special method that acts as a cog local pre-invoke hook. @@ -280,6 +288,7 @@ class Cog(metaclass=CogMeta): """ pass + @_cog_special_method async def cog_after_invoke(self, ctx): """A special method that acts as a cog local post-invoke hook.