[commands] Add Command/Cog.has_error_handler
This allows querying the state without relying on internal undocumented attributes.
This commit is contained in:
parent
73a783cd6b
commit
b9a99238e8
@ -296,6 +296,13 @@ class Cog(metaclass=CogMeta):
|
|||||||
return func
|
return func
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
def has_error_handler(self):
|
||||||
|
""":class:`bool`: Checks whether the cog has an error handler.
|
||||||
|
|
||||||
|
.. versionadded:: 1.7
|
||||||
|
"""
|
||||||
|
return hasattr(self.cog_command_error.__func__, '__cog_special_method__')
|
||||||
|
|
||||||
@_cog_special_method
|
@_cog_special_method
|
||||||
def cog_unload(self):
|
def cog_unload(self):
|
||||||
"""A special method that is called when the cog gets removed.
|
"""A special method that is called when the cog gets removed.
|
||||||
|
@ -904,6 +904,13 @@ class Command(_BaseCommand):
|
|||||||
self.on_error = coro
|
self.on_error = coro
|
||||||
return coro
|
return coro
|
||||||
|
|
||||||
|
def has_error_handler(self):
|
||||||
|
""":class:`bool`: Checks whether the command has an error handler registered.
|
||||||
|
|
||||||
|
.. versionadded:: 1.7
|
||||||
|
"""
|
||||||
|
return hasattr(self, 'on_error')
|
||||||
|
|
||||||
def before_invoke(self, coro):
|
def before_invoke(self, coro):
|
||||||
"""A decorator that registers a coroutine as a pre-invoke hook.
|
"""A decorator that registers a coroutine as a pre-invoke hook.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user