Skip to content

Commit 86ec9a0

Browse files
committed
Fix the before/after invoke docs
1 parent 0759081 commit 86ec9a0

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

twitchio/ext/commands/bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ async def after_invoke(self, ctx: Context) -> None:
452452
Commands from :class:`~.commands.Component`'s are included, however if you wish to control them separately,
453453
see: :meth:`~.commands.Component.component_after_invoke`.
454454
455-
The post-invoke hook will be called after a valid command has been invoked. If this coroutine errors,
455+
The post-invoke hook will be called after a valid command has completed invocation. If this coroutine errors,
456456
a :exc:`~.commands.CommandHookError` will be raised from the original error.
457457
458458
Useful for cleaning up any state like database connections or http clients.

twitchio/ext/commands/core.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -621,9 +621,11 @@ def error(self, func: Any) -> Any:
621621
def before_invoke(self, func: Any) -> Any:
622622
"""|deco|
623623
624-
A decorator which adds a local ``before_invoke`` callback to this command.
624+
A decorator which adds a local ``before_invoke`` callback to this command, similar to
625+
:meth:`~twitchio.ext.commands.Bot.before_invoke` except local to this command.
625626
626-
Similar to :meth:`~twitchio.ext.commands.Bot.before_invoke` except local to this command.
627+
The ``before_invoke`` hook is called before the command callback, but after parsing arguments and guards are
628+
successfully completed. Could be used to setup state for the command for example.
627629
628630
Example
629631
-------
@@ -659,9 +661,17 @@ async def test_after(ctx: commands.Context) -> None:
659661
def after_invoke(self, func: Any) -> Any:
660662
"""|deco|
661663
662-
A decorator which adds a local ``after_invoke`` callback to this command.
664+
A decorator which adds a local ``after_invoke`` callback to this command, similar to
665+
:meth:`~twitchio.ext.commands.Bot.after_invoke` except local to this command.
666+
667+
The ``after_invoke`` hook is called after the command callback has completed invocation. Could be used to cleanup
668+
state after command invocation.
669+
670+
.. note::
671+
672+
This hook is always called; even when the :class:`~.commands.Command` fails to invoke. However, similar to
673+
:meth:`.before_invoke` only if parsing arguments and guards are successfully completed.
663674
664-
Similar to :meth:`~twitchio.ext.commands.Bot.after_invoke` except local to this command.
665675
666676
Example
667677
-------

0 commit comments

Comments
 (0)