Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ There are several different internal events:

- ``raw_socket_create``
- ``on_start``
- ``on_disconnect``
- ``on_interaction``
- ``on_command``
- ``on_command_error``
Expand Down Expand Up @@ -82,6 +83,13 @@ This function takes no arguments.
.. attention::
Unlike ``on_ready``, this event will never be dispatched more than once.

Event: ``on_disconnect``
^^^^^^^^^^^^^^^^^^^^^^^^^^^
This event fires whenever the conenction is invalidated, and will often precede an ``on_ready`` event

This function takes no arguments.


Event: ``on_interaction``
^^^^^^^^^^^^^^^^^^^^^^^^^^^
This event fires on any interaction (commands, components, autocomplete and modals).
Expand Down
3 changes: 3 additions & 0 deletions interactions/api/gateway/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ async def _handle_stream(self, stream: Dict[str, Any]):
if op == OpCodeType.INVALIDATE_SESSION:
log.debug("INVALID_SESSION")
self.ready.clear()
self._dispatch.dispatch(
"on_disconnect"
) # will be followed by the on_ready event after reconnection
await self._reconnect(bool(data))

if op == OpCodeType.RECONNECT:
Expand Down