discord.payload module¶
- 
class discord.payload.Payload(opcode, data, seq_number=None, event_name=None)[source]¶
- Bases: - object- A discord gateway payload as described here: https://discordapp.com/developers/docs/topics/gateway#payloads - Parameters: - opcode – Opcode for the payload. (as described here: https://discordapp.com/developers/docs/topics/opcodes-and-status-codes#gateway-opcodes)
- data – A dictionary containing the payload data.
- seq_number – sequence number, used for resuming sessions and heartbeats.
- event_name – the event name for this payload.
 - 
DISPATCH= 0¶
 - 
HEARTBEAT= 1¶
 - 
IDENTIFY= 2¶
 - 
STATUS_UPDATE= 3¶
 - 
VOICE_UPDATE= 4¶
 - 
RESUME= 6¶
 - 
RECONNECT= 7¶
 - 
REQUEST_MEMB= 8¶
 - 
INVALID= 9¶
 - 
HELLO= 10¶
 - 
HEARTBEAT_ACK= 11¶
 - 
static from_packet(packet)[source]¶
- Creates a Payload from the raw string received through the gateway websocket. - Parameters: - packet – The json string receveid from the gateway. - Returns: - A Payload. 
 - 
to_packet()[source]¶
- Encodes the payload in json in a format recognized by discord’s APIs. - Returns: - A json string. 
 - 
static Resume(token, session_id, last_seq)[source]¶
- Creates a RESUME payload. - Parameters: - token – The bot token.
- session_id – The id of the session that was opened with the gateway’s websocket.
- last_seq – The last payload sequence number received before the connection was interrupted.
 - Returns: - A RESUME Payload.