Skip to content

Commit db56b4d

Browse files
authored
docs: document on_start in more places (#931)
1 parent 469f2db commit db56b4d

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

docs/migration.rst

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,34 @@ portal and add the intent to your current intents when connecting:
6666
4.1.0 → 4.3.0
6767
~~~~~~~~~~~~~~~
6868

69-
A new big change in this release is the implementation of the ``get`` utility method.
69+
A new feature was added; an event called ``on_start``.
70+
Unlike ``on_ready``, this event is only dispatched when the bot is first started.
71+
72+
Instead of using the ``on_ready`` event and a check to only run code once:
73+
74+
.. code-block:: python
75+
76+
_ready: bool = False
77+
bot = interactions.Client(...)
78+
79+
@bot.event
80+
async def on_ready():
81+
global _ready
82+
if not _ready:
83+
... # do stuff
84+
_ready = True
85+
86+
You can now utilize the ``on_start`` event to achieve the same goal:
87+
88+
.. code-block:: python
89+
90+
bot = interactions.Client(...)
91+
92+
@bot.event
93+
async def on_start():
94+
... # do stuff
95+
96+
Another big change in this release is the implementation of the ``get`` utility method.
7097
It allows you to no longer use ``**await bot._http...``.
7198

7299
You can get more information by reading the `get-documentation`_.

interactions/api/gateway/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class WebSocketClient:
6060
:ivar Optional[ClientPresence] __presence: The presence used in connection.
6161
:ivar Event ready: The ready state of the client as an ``asyncio.Event``.
6262
:ivar Task __task: The closing task for ending connections.
63+
:ivar bool __started: Whether the client has started.
6364
:ivar Optional[str] session_id: The ID of the ongoing session.
6465
:ivar Optional[int] sequence: The sequence identifier of the ongoing session.
6566
:ivar float _last_send: The latest time of the last send_packet function call since connection creation, in seconds.

0 commit comments

Comments
 (0)