- Quickstart
- API Reference
- Frequently Asked Questions
- discord.py is dead! Will this library die too?
- Are you going to/will/consider fork(ing) discord.py?
- Will discord.py be able to work with this library?
- Where should we go with discord.py being gone?
- Why are you not supporting cooldowns?
- Will we not be able to create message commands?
- My question is not answered on here!
Gateway¶
- class interactions.api.gateway.Heartbeat(ws: Any, interval: int)
A class representing a consistent heartbeat connection with the gateway.
- Variables
ws (interactions.api.gateway.WebSocket) – The WebSocket class to infer on.
interval (typing.Union[int, float]) – The heartbeat interval determined by the gateway.
event (threading.Event) – The multi-threading event.
- run() None
Starts the heartbeat connection.
- stop() None
Stops the heartbeat connection.
- class interactions.api.gateway.WebSocket(intents: interactions.api.models.intents.Intents, session_id: Optional[int] = None, sequence: Optional[int] = None)
A class representing a websocket connection with the gateway.
- Variables
intents (interactions.api.models.intents.Intents) – An instance of
interactions.api.models.Intents
.loop (asyncio.AbstractEventLoop) – The coroutine event loop established on.
req (interactions.api.http.Request) – An instance of
interactions.api.http.Request
.dispatch (interactions.api.dispatch.Listener) – An instance of
interactions.api.dispatch.Listener
.session (typing.Any) – The current client session.
session_id (int) – The current ID of the gateway session.
sequence (int) – The current sequence of the gateway connection.
keep_alive (interactions.api.gateway.Heartbeat) – An instance of
interactions.api.gateway.Heartbeat
.closed (bool) – The current connection state.
http (interactions.api.http.HTTPClient) – The internal HTTP client used to connect to the gateway.
options (dict) – The websocket connection options.
- async recv() Optional[Any]
Receives packets sent from the gateway.
- async connect(token: str) None
Establishes a connection to the gateway.
- Parameters
token (str) – The token to use for identifying.
- Returns
None
- contextualize(data: dict) object
Takes raw data given back from the gateway and gives “context” based off of what it is.
- Parameters
data (dict) – The data from the gateway.
- Returns
The context object.
- async identify() None
Sends an
IDENTIFY
packet to the gateway.
- async resume() None
Sends a
RESUME
packet to the gateway.
- async heartbeat() None
Sends a
HEARTBEAT
packet to the gateway.