Gateway

Gateway URL

wss://gateway.discordbots.group

Payload Format

Field

Type

Description

Present

op

Number

opcode for the payload

Yes

t

Number

Timestamp for when the payload was sent

Yes

data

?Object

Data for payload

Yes

Payloads

OP Code

Name

Description

Client Action

0

Identify

Identifies who is connected to the gateway. This should contain an array of bot tokens.

Send

1

Heartbeat

Used for checking the connection is still alive.

Send

2

Heartbeat Acknowledgement

Sent after heartbeat is received.

Receive

3

Bot Upvote

Sent whenever a bot is upvoted.

Receive

4

Page View

Sent whenever a user requests bot information

Receive

Close Codes

Code

Message

Description

4000

Unknown Error

Something went badly wrong.

4001

Invalid OP

Payload contained an invalid OP code.

4002

Invalid Payload

Payload didn't fit required requirements.

4003

Failed to identify

Failed to identify client. Timeout is 15 seconds.

4004

Unauthorized / Invalid identification

Non of the bot tokens were successfully authorized.

4005

No heartbeat

No heartbeat was sent in the past 60 seconds.

OP 0 - Identify

This should be the first event sent from the client after connection. Idenftifies who is connected by using a list of bot tokens. The bot tokens will be used to authorize who is connected and who to send events to. If non of the tokens are valid the WebSocket will close with a 4004 Invalid identificationerror. The client can be re-identified at anytime.

{
"op": 0,
"t": 1556357799169,
"data": {
"tokens": [
'8dff57acd7caf842d9cf198880bed2a1880f',
'e2ffecc00d25564fdce01ba9ef25d5f16549'
]
}
}

OP 1 - Heartbeat

Heartbeats ensure the connection is still alive, and that the server shouldn't send payloads to a dead client. The payload should be sent in under 60 seconds. If the server doesn't receive a heartbeat the connection will be closed with a 4005 - No heartbeaterror.

{
"op": 1,
"t": 1556357799169,
"data": {}
}

OP 2 - Heartbeat Acknowledgement

Sent when server receives heartbeat from client.

{
"op": 2,
"t": 1556357799169,
"data": {}
}

OP 3 - Bot Upvote

Sent whenever a user upvotes a bot.

{
"op":3,
"t":1556358808931,
"data": {
"bot":"512250403384066068",
"user": {
"id":"449653897695461376",
"username":"DetectiveHuman",
"discriminator":1234,
"avatar":"..."
}
}
}
‚Äč

OP 4 - Page View

Sent whenever bot information is requested

{
"op":4,
"t":1556358973059,
"data": {
"bot":"512250403384066068"
}
}