discord.gateway module¶
-
class
discord.gateway.
Gateway
(token, message_queue, GatewayConnection=<class 'discord.gateway_connection.GatewayConnection'>, logging=<module 'logging' from '/opt/python/3.6.3/lib/python3.6/logging/__init__.py'>)[source]¶ Bases:
object
An interface for discord’s gateway API as described here: https://discordapp.com/developers/docs/topics/gateway
Parameters: - token – The bot token.
- message_queue – An empty queue that the gateway will dispatch received messages into.
- wslib – A websocket library.
-
DEFAULT_HEARTBEAT_PERIOD
= 45¶
-
OS
= 'linux'¶
-
NAME
= 'Charlotte'¶
-
MIN_RECONNECTION_WAIT
= 5¶
-
MAX_RECONNECTION_WAIT
= 1800¶
-
connection_interval
¶
-
perform_handshake
(connection, resume=False)[source]¶ Waits for the gateway to say hello then identifies with it and waits for its READY acknowledgment. In the process the heartbeat interval and session ID are defined.
Raises: - AssertionError – Unexpected behaviour from the gateway during the handshake.
- KeyError – Handshake messages did not contain necessary information.
-
send_heartbeats
(connection)[source]¶ Sends heartbeats at the chosen heartbeat interval until told to stop or the connection drops, in which case it’ll attempt to reconnect.