ILLEST Developers

The gateway

A bot talks to ILLEST over one WebSocket, the same one the apps use. There is no separate REST API: every request is a frame on the socket, and its answer comes back on it. illest.py speaks it for you; this page is for writing a library of your own, or for reading what illest.py does.

Frames

Every frame is one JSON object, at most 1 MiB:

JSON
{ "v": 2, "op": "REQ", "id": "7", "t": "message.send", "d": { "channel_id": "...", "ciphertext": "..." } }
FieldWhat it holds
vthe protocol's version, 2
opwhat kind of frame it is
idon a request, any text of yours; its answer carries the same
ta request's action, or an event's name
dthe body
seqon an event, its place in the session, for resuming
okon an answer, whether it worked
Op
HELLO
IDENTIFY
RESUME
READY
RESUMED
INVALID_SESSION
REQ
RES
DISPATCH
HEARTBEAT
HEARTBEAT_ACK
ERROR

A session

  1. Open the socket. The server sends HELLO with a nonce and the heartbeat interval (heartbeat_ms).
  2. Send IDENTIFY with the session token, and a signature over the nonce made with the bot's device key. The server answers READY, with who the bot is, the servers and channels it is in, and the encrypted groups it holds.
  3. Send HEARTBEAT at the interval. A socket that stops answering is closed.
  4. Send REQ frames; each gets a RES with the same id. Events arrive as DISPATCH frames.
  5. After a drop, send RESUME with the last seq you saw. The server replays what you missed and answers RESUMED, or INVALID_SESSION, after which you IDENTIFY again.

A bot gets its session token by signing in with its bot token through bot.identify, which also registers its device key on the first run (illest.py's auth.py).

Answers and errors

A refused request is a RES with ok: false and d: { "code": "...", "message": "..." }. illest.py raises the matching exception: Forbidden, NotFound, RateLimited, MissingScope and so on.

Code
BAD_ENVELOPE
UNSUPPORTED_VERSION
FRAME_TOO_LARGE
NOT_AUTHENTICATED
ALREADY_AUTHENTICATED
AUTH_FAILED
UNKNOWN_ACTION
BAD_REQUEST
FORBIDDEN
NOT_FOUND
RATE_LIMITED
STALE_EPOCH
MESSAGE_EPOCH_STALE
ROSTER_STALE
RESET_COOLDOWN
INTERNAL

Events

What the server sends as DISPATCH, and the library's events each becomes. Most of what a bot reads (messages, edits, reactions, commands, presses and forms) arrives sealed inside message.create and is opened on the bot's side. Events lists every event with its arguments.

FrameBecomes
message.createon_interaction, on_message, on_message_delete, on_message_edit, on_raw_message_delete, on_raw_message_edit, on_raw_reaction_add, on_raw_reaction_remove, on_reaction_add, on_reaction_remove
mls.welcomeon_group_join
mls.commitnone
mls.key_packages.lownone
interaction.clicknone
guild.member.addon_guild_join, on_member_join
guild.member.removeon_guild_remove, on_member_ban, on_member_remove, on_raw_member_remove
guild.member.updateon_member_update
guild.removeon_guild_remove
guild.deleteon_guild_remove
guild.updateon_guild_channel_create, on_guild_channel_delete, on_guild_channel_update, on_guild_role_create, on_guild_role_delete, on_guild_role_update, on_guild_update
guild.unbanon_member_unban
channel.typingon_raw_typing, on_typing
message.redacton_message_delete, on_message_redact, on_raw_message_delete
user.updateon_user_update
presence.updateon_presence_update
voice.stateon_voice_state_update
channel.pins.updateon_guild_channel_pins_update, on_private_channel_pins_update
channel.stalenone

Actions

What a bot may send as REQ, the scopes each needs and its rate limit: bot actions.