[commands] Add on_command and on_command_completion events.
This commit is contained in:
parent
855fa7e553
commit
bc7606a42c
@ -514,7 +514,8 @@ class Bot(GroupMixin, discord.Client):
|
|||||||
--------
|
--------
|
||||||
This function is necessary for :meth:`say`, :meth:`whisper`,
|
This function is necessary for :meth:`say`, :meth:`whisper`,
|
||||||
:meth:`type`, :meth:`reply`, and :meth:`upload` to work due to the
|
:meth:`type`, :meth:`reply`, and :meth:`upload` to work due to the
|
||||||
way they are written.
|
way they are written. It is also required for the :func:`on_command`
|
||||||
|
and :func:`on_command_completion` events.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
-----------
|
-----------
|
||||||
@ -553,8 +554,10 @@ class Bot(GroupMixin, discord.Client):
|
|||||||
|
|
||||||
if invoker in self.commands:
|
if invoker in self.commands:
|
||||||
command = self.commands[invoker]
|
command = self.commands[invoker]
|
||||||
|
self.dispatch('command', command, ctx)
|
||||||
ctx.command = command
|
ctx.command = command
|
||||||
yield from command.invoke(ctx)
|
yield from command.invoke(ctx)
|
||||||
|
self.dispatch('command_completion', command, ctx)
|
||||||
else:
|
else:
|
||||||
exc = CommandNotFound('Command "{}" is not found'.format(invoker))
|
exc = CommandNotFound('Command "{}" is not found'.format(invoker))
|
||||||
self.dispatch('command_error', exc, ctx)
|
self.dispatch('command_error', exc, ctx)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user