mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-15 10:19:59 +00:00
[commands] Implement Command.__call__
This commit is contained in:
parent
02397306b2
commit
d9cd4a3561
@ -335,6 +335,24 @@ class Command(_BaseCommand):
|
|||||||
"""
|
"""
|
||||||
self.__init__(self.callback, **dict(self.__original_kwargs__, **kwargs))
|
self.__init__(self.callback, **dict(self.__original_kwargs__, **kwargs))
|
||||||
|
|
||||||
|
async def __call__(self, *args, **kwargs):
|
||||||
|
"""|coro|
|
||||||
|
|
||||||
|
Calls the internal callback that the command holds.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
This bypasses all mechanisms -- including checks, converters,
|
||||||
|
invoke hooks, cooldowns, etc. You must take care to pass
|
||||||
|
the proper arguments and types to this function.
|
||||||
|
|
||||||
|
.. versionadded:: 1.3
|
||||||
|
"""
|
||||||
|
if self.cog is not None:
|
||||||
|
return await self.callback(self.cog, *args, **kwargs)
|
||||||
|
else:
|
||||||
|
return await self.callback(*args, **kwargs)
|
||||||
|
|
||||||
def _ensure_assignment_on_copy(self, other):
|
def _ensure_assignment_on_copy(self, other):
|
||||||
other._before_invoke = self._before_invoke
|
other._before_invoke = self._before_invoke
|
||||||
other._after_invoke = self._after_invoke
|
other._after_invoke = self._after_invoke
|
||||||
|
@ -73,6 +73,7 @@ Command
|
|||||||
|
|
||||||
.. autoclass:: discord.ext.commands.Command
|
.. autoclass:: discord.ext.commands.Command
|
||||||
:members:
|
:members:
|
||||||
|
:special-members: __call__
|
||||||
|
|
||||||
.. autoclass:: discord.ext.commands.Group
|
.. autoclass:: discord.ext.commands.Group
|
||||||
:members:
|
:members:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user