tether developers
Contents

API reference

Gateway

The WebSocket a bot listens on: how to connect, what it sends, and every event.

Connect to wss://<server>/gateway (a library asks GET /gateway/bot for it), with version 1. Messages are JSON, never compressed.

Opcodes

DISPATCH0 · receive
An event. t is its name, d its payload and s its sequence number (keep the last one for heartbeats and resuming).
HEARTBEAT1 · both
Send it every heartbeat_interval milliseconds (HELLO tells you; 41.25 seconds by default) with d the last sequence number, or null. A connection that sends none for 1.5 intervals plus 5 seconds is closed with 4009. The server may also ask for one.
IDENTIFY2 · send
Start a session: {token: "Bot <token>", intents, properties?, shard?, presence?}. intents is a bitfield (see Intents); leave it out for everything. 30 identifies a minute per address. A wrong token closes with 4004.
PRESENCE_UPDATE3 · send
Change your presence: {status, afk?, activities?, since?}. status is online, idle, dnd or invisible. activities takes one "Playing" game (type 0); other types are ignored.
VOICE_STATE_UPDATE4 · send
Join, move or leave a voice channel: {guild_id, channel_id, self_mute, self_deaf}; channel_id: null leaves. tether adds an optional e2ee_key (the app's public key for an encrypted call; a bot never sends it, and is refused in an encrypted channel). tether answers with VOICE_SERVER_UPDATE (a LiveKit address and token), or VOICE_STATE_ERROR if refused. See The music player and the voice notes in Coming from Discord.
RESUME6 · send
Pick a dropped session up again: {token, session_id, seq}. The server replays what you missed (up to 1000 events, within 2 minutes of the drop) and ends with RESUMED; if it cannot, it sends INVALID_SESSION false and you IDENTIFY again. Sessions resume only on the same server process.
RECONNECT7 · receive
Reconnect and resume. Defined, not sent today.
REQUEST_GUILD_MEMBERS8 · send
Ask for members: {guild_id, query?, limit?, user_ids?, presences?, nonce?}. Answered with GUILD_MEMBERS_CHUNK to your session only. tether sends every member in GUILD_CREATE already, so this is for libraries that ask anyway.
INVALID_SESSION9 · receive
Your session is gone. d is whether it is resumable (always false today): IDENTIFY again.
HELLO10 · receive
The first frame: {heartbeat_interval}. Start heartbeating, then IDENTIFY or RESUME.
HEARTBEAT_ACK11 · receive
Your heartbeat arrived.

Close codes

UNKNOWN_ERROR4000 · reconnect
Something went wrong on the server, or the session was resumed elsewhere.
UNKNOWN_OPCODE4001 · reconnect
You sent an opcode the server does not know.
DECODE_ERROR4002 · reconnect
A frame was not valid JSON text, was binary, or its data was not what the opcode takes. Frames are at most 16 KiB.
NOT_AUTHENTICATED4003 · reconnect
You sent something before IDENTIFY, or never identified in time.
AUTHENTICATION_FAILED4004 · do not reconnect
The token is wrong, reset, or revoked. Make a new one (Reset Bot Token) and use it. Do not retry with the same token.
ALREADY_AUTHENTICATED4005 · reconnect
You identified twice on one connection.
INVALID_SEQ4007 · reconnect
Discord's "invalid sequence on resume". Defined, not sent today (an impossible resume is INVALID_SESSION).
RATE_LIMITED4008 · reconnect
More than 120 frames in a minute on one connection, or more than 30 identifies a minute from one address.
SESSION_TIMED_OUT4009 · reconnect
No heartbeat in time. RESUME if you can.
INVALID_API_VERSION4012 · do not reconnect
Discord's "invalid version". Defined, not sent today: the gateway accepts any v and ignores it.
INVALID_INTENTS4013 · do not reconnect
The intents value is not a bitfield at all (negative or fractional, or not a number). Bits that are not defined are ignored, never a reason to refuse.
UNVERIFIED_ACCOUNT4100 · do not reconnect
tether's own. A person's account has not confirmed its email on a server that sends email. Bots are not affected.
MISSING_SCOPE4101 · do not reconnect
tether's own. A sign-in with tether app session sent something its scopes do not allow. Bots are not affected.
BIRTHDAY_REQUIRED4102 · do not reconnect
tether's own. A person's account has not given its birthday yet (accounts made before birthdays were asked for): the app asks once, then connects. Bots are not affected.

Intents

GUILDS1 << 0 · 1
Server, channel, thread, role, welcome and bot-settings events.
GUILD_MEMBERS1 << 1 · 2 · privileged
Member add, update and remove, and thread member changes. Not gated by approval.
GUILD_MODERATION1 << 2 · 4
Bans, audit log entries, ban appeals and moderation cases.
GUILD_EXPRESSIONS1 << 3 · 8
Custom emoji and sticker updates (tether has no soundboard).
GUILD_INTEGRATIONS1 << 4 · 16
Accepted; no event depends on it (tether has no integrations).
GUILD_WEBHOOKS1 << 5 · 32
Accepted; no event depends on it (tether has no channel webhooks).
GUILD_INVITES1 << 6 · 64
Invite create and delete.
GUILD_VOICE_STATES1 << 7 · 128
Voice state updates, and the player's and theatre's events for voice channels.
GUILD_PRESENCES1 << 8 · 256 · privileged
Presence updates. Not gated by approval.
GUILD_MESSAGES1 << 9 · 512
Message create, update, delete and bulk delete in servers.
GUILD_MESSAGE_REACTIONS1 << 10 · 1024
Reaction events in servers.
GUILD_MESSAGE_TYPING1 << 11 · 2048
Typing in servers.
DIRECT_MESSAGES1 << 12 · 4096
Messages, pins and calls in direct messages.
DIRECT_MESSAGE_REACTIONS1 << 13 · 8192
Reaction events in direct messages.
DIRECT_MESSAGE_TYPING1 << 14 · 16384
Typing in direct messages.
MESSAGE_CONTENT1 << 15 · 32768 · privileged
Accepted and does nothing: the text of a message reaches a bot by the server's rule (mention, prefix, or full content), not by this bit. See Privacy for bots.
GUILD_SCHEDULED_EVENTS1 << 16 · 65536
Scheduled events: made, changed, started, ended, deleted, and people marking themselves interested.
AUTO_MODERATION_CONFIGURATION1 << 20 · 1048576
Auto-mod rule events (to people who manage the server).
AUTO_MODERATION_EXECUTION1 << 21 · 2097152
What auto-mod did (never with the message text).
GUILD_MESSAGE_POLLS1 << 24 · 16777216
Poll votes in servers.
DIRECT_MESSAGE_POLLS1 << 25 · 33554432
Poll votes in direct messages.

Events

READY
After IDENTIFY: your user, session_id, resume_gateway_url, and for a bot application: {id, flags, player}. Guilds arrive as {id, unavailable: true}; a GUILD_CREATE follows for each. Fields that are for people (relationships, read_state, dm_layout…) are empty for a bot. tether adds dm_threads: the active (not archived) threads of the DMs and group DMs you are in, newest first, at most 500 (APIThread, with no guild_id; Threads in DMs). An app session (sign in with tether) never gets it.

payload GatewayReadyData · no intent

RESUMED
After a RESUME: everything missed has been replayed. d is an empty object (never null).

payload Record<string, never> · no intent

GUILD_CREATE
A server you are in, on connect and when you are added (the add link, Add Bot to Server). It carries the whole server: channels you can see, active threads, every member, voice states, and tether's player_sessions and theatre_sessions.

payload GatewayGuildCreateData · intent GUILDS

GUILD_UPDATE
The server's settings changed (name, icon, banner…).

payload APIGuild · intent GUILDS

GUILD_DELETE
You are no longer in the server (removed, banned, left, or the server was deleted). unavailable is false.

payload GatewayGuildDeleteData · intent GUILDS

GUILD_ROLE_CREATE
A role was made.

payload GatewayGuildRoleData · intent GUILDS

GUILD_ROLE_UPDATE
A role changed (name, colour, permissions, position).

payload GatewayGuildRoleData · intent GUILDS

GUILD_ROLE_DELETE
A role was deleted. A bot's managed role goes when the bot leaves.

payload GatewayGuildRoleDeleteData · intent GUILDS

GUILD_ROLE_MENU_CREATE
A role menu was made. Only to people who can manage roles.

payload APIRoleMenu · intent GUILDS · tether only

GUILD_ROLE_MENU_UPDATE
A role menu changed. Only to people who can manage roles.

payload APIRoleMenu · intent GUILDS · tether only

GUILD_ROLE_MENU_DELETE
A role menu was deleted (its ids). Only to people who can manage roles.

payload GatewayRoleMenuDeleteData · intent GUILDS · tether only

GUILD_MEMBER_ADD
Someone joined.

payload GatewayGuildMemberAddData · intent GUILD_MEMBERS

GUILD_MEMBER_UPDATE
A member changed: nickname, roles, timeout, rules gate.

payload GatewayGuildMemberUpdateData · intent GUILD_MEMBERS

GUILD_MEMBER_REMOVE
Someone left, was kicked or was banned.

payload GatewayGuildMemberRemoveData · intent GUILD_MEMBERS

GUILD_MEMBERS_CHUNK
The answer to opcode 8, to the asking session only.

payload GatewayGuildMembersChunkData · no intent

GUILD_BAN_ADD
Someone was banned.

payload GatewayGuildBanData · intent GUILD_MODERATION

GUILD_BAN_REMOVE
A ban was lifted.

payload GatewayGuildBanData · intent GUILD_MODERATION

GUILD_AUDIT_LOG_ENTRY_CREATE
A new audit log entry, only to people (and bots) with View Audit Log. A bot never gets the message text that a bulk-delete entry keeps.

payload GatewayAuditLogEntryCreateData · intent GUILD_MODERATION

GUILD_WELCOME_UPDATE
The welcome settings changed. Only to people who can manage the server.

payload GatewayGuildWelcomeUpdateData · intent GUILDS · tether only

GUILD_EMOJIS_UPDATE
The server's custom emoji changed: the complete new list.

payload GatewayGuildEmojisUpdateData · intent GUILD_EXPRESSIONS

GUILD_STICKERS_UPDATE
The server's stickers changed: the complete new list.

payload GatewayGuildStickersUpdateData · intent GUILD_EXPRESSIONS

GUILD_SCHEDULED_EVENT_CREATE
An event was planned (the event). Voice events go only to people who can see the channel.

payload APIGuildScheduledEvent · intent GUILD_SCHEDULED_EVENTS

GUILD_SCHEDULED_EVENT_UPDATE
An event changed: its words or times, and also when it starts, ends, is canceled or rolls to its next time (the event, with its new status).

payload APIGuildScheduledEvent · intent GUILD_SCHEDULED_EVENTS

GUILD_SCHEDULED_EVENT_DELETE
An event was deleted (the event as it was).

payload APIGuildScheduledEvent · intent GUILD_SCHEDULED_EVENTS

GUILD_SCHEDULED_EVENT_USER_ADD
Someone marked themselves interested: {guild_scheduled_event_id, user_id, guild_id}.

payload GatewayScheduledEventUserData · intent GUILD_SCHEDULED_EVENTS

GUILD_SCHEDULED_EVENT_USER_REMOVE
Someone took their interest back (same shape).

payload GatewayScheduledEventUserData · intent GUILD_SCHEDULED_EVENTS

CHANNEL_CREATE
A channel was made (only if you can see it), or a DM opened.

payload APIChannel | APIDMChannel · intent GUILDS

CHANNEL_UPDATE
A channel changed, including its permission overwrites, lock and sticky message.

payload APIChannel | APIDMChannel · intent GUILDS

CHANNEL_DELETE
A channel was deleted.

payload APIChannel | APIDMChannel · intent GUILDS

THREAD_CREATE
A thread was made, or you were added to one. newly_created is true for a new one.

payload GatewayThreadCreateData · intent GUILDS

THREAD_UPDATE
A thread changed: renamed, archived, locked, slow mode.

payload APIThread · intent GUILDS

THREAD_DELETE
A thread was deleted.

payload GatewayThreadDeleteData · intent GUILDS

THREAD_LIST_SYNC
You gained access to a text channel: its active threads.

payload GatewayThreadListSyncData · intent GUILDS

THREAD_MEMBER_UPDATE
Your own membership of a thread changed. To you only.

payload GatewayThreadMemberUpdateData · intent GUILDS

THREAD_MEMBERS_UPDATE
People joined or left a thread.

payload GatewayThreadMembersUpdateData · intent GUILD_MEMBERS

CHANNEL_PINS_UPDATE
A message was pinned or unpinned.

payload GatewayChannelPinsUpdateData · intent GUILDS

INVITE_CREATE
An invite was made. To members who can manage the channel it is for.

payload APIInvite · intent GUILD_INVITES

INVITE_DELETE
An invite was deleted. To members who can manage the channel it was for.

payload { channel_id: Snowflake; guild_id: Snowflake; code: string } · intent GUILD_INVITES

MESSAGE_CREATE
A message was sent in a channel you can see. A bot gets the text only if the message mentions it, starts with its prefix, is its own, or its server turned full content on; otherwise content, embeds and attachments are empty.

payload GatewayMessageCreateData · intent GUILD_MESSAGES

MESSAGE_UPDATE
A message was edited (same content rule as MESSAGE_CREATE). It has no reactions; fetch them over REST.

payload GatewayMessageUpdateData · intent GUILD_MESSAGES

MESSAGE_DELETE
A message was deleted.

payload GatewayMessageDeleteData · intent GUILD_MESSAGES

MESSAGE_DELETE_BULK
Several messages were deleted at once.

payload GatewayMessageDeleteBulkData · intent GUILD_MESSAGES

MESSAGE_REACTION_ADD
Someone reacted.

payload GatewayMessageReactionAddData · intent GUILD_MESSAGE_REACTIONS

MESSAGE_REACTION_REMOVE
Someone took a reaction back.

payload GatewayMessageReactionRemoveData · intent GUILD_MESSAGE_REACTIONS

MESSAGE_REACTION_REMOVE_ALL
Every reaction was removed from a message.

payload GatewayMessageReactionRemoveAllData · intent GUILD_MESSAGE_REACTIONS

MESSAGE_REACTION_REMOVE_EMOJI
Every reaction of one emoji was removed from a message.

payload GatewayMessageReactionRemoveEmojiData · intent GUILD_MESSAGE_REACTIONS

MESSAGE_POLL_VOTE_ADD
Someone chose an answer in a poll.

payload GatewayMessagePollVoteData · intent GUILD_MESSAGE_POLLS

MESSAGE_POLL_VOTE_REMOVE
Someone took their choice back.

payload GatewayMessagePollVoteData · intent GUILD_MESSAGE_POLLS

MESSAGE_ACK
Your read position moved (a person's own sessions only).

payload GatewayMessageAckData · no intent · people only · tether only

TYPING_START
Someone started typing.

payload GatewayTypingStartData · intent GUILD_MESSAGE_TYPING

PRESENCE_UPDATE
A member's presence changed.

payload APIPresence · intent GUILD_PRESENCES

USER_UPDATE
Your own account changed (name, picture, status). To your own sessions only.

payload APICurrentUser · no intent

USER_SETTINGS_UPDATE
Your custom status, your server folders or your language changed; only what changed is sent (a person's own sessions only).

payload Partial<APIUserSettings> · no intent · people only · tether only

USER_CONNECTIONS_UPDATE
Your linked accounts changed (a person's own sessions only).

payload GatewayUserConnectionsUpdateData · no intent · people only · tether only

VOICE_STATE_UPDATE
Someone joined, left or changed state in a voice channel. A music bot hidden by "Hide in voice channels" is left out for everyone but itself.

payload APIVoiceState · intent GUILD_VOICE_STATES

VOICE_SERVER_UPDATE
The answer to opcode 4: {guild_id, channel_id, endpoint, token, e2ee, host}. endpoint is a LiveKit URL and token a LiveKit access token for that one room. e2ee and host are tether's: e2ee is true when the room is end-to-end encrypted (bots are never let into one), host is {kind, id, name} when someone else's computer or a server's own voice server hosts the room (always encrypted), else null. To the asking session only.

payload GatewayVoiceServerUpdateData · no intent

VOICE_STATE_ERROR
An opcode 4 request was refused, with code and message (Discord silently ignores a refused join). To the asking session only.

payload GatewayVoiceStateErrorData · no intent · tether only

VOICE_E2EE_KEY
Someone in your encrypted call sent you their media key: {channel_id, guild_id, sender_id, generation, box}. To the session that owns your voice connection only. Bots are never in an encrypted call, so they never get it.

payload GatewayVoiceE2eeKeyData · no intent · people only · tether only

VOICE_E2EE_KEY_REQUEST
Someone in your encrypted call is missing your key: {channel_id, guild_id, requester_id}. To the session that owns your voice connection only.

payload GatewayVoiceE2eeKeyRequestData · no intent · people only · tether only

VOICE_HOST_OFFER
Someone started hosting the voice channel you are in on their computer: {guild_id, channel_id, host: {kind, id, name}, expires_at}. Hosting shows the host everyone's IP address, so you are asked. Accept by sending opcode 4 for the same channel with voice_host_consent: host.id before expires_at (20 seconds); anyone who does not is disconnected. To the session that owns your voice connection only. Bots never get it (hosted rooms are always encrypted).

payload GatewayVoiceHostOfferData · no intent · people only · tether only

VOICE_CHANNEL_EFFECT_SEND
Someone in a voice channel sent a reaction: {channel_id, guild_id, user_id, emoji, animation_type, animation_id}, as Discord's. tether sends it for the five emoji of the call screen (POST /channels/{channel.id}/voice-channel-effects) and only to people in that voice channel.

payload GatewayVoiceChannelEffectSendData · intent GUILD_VOICE_STATES

INTERACTION_CREATE
Bots only. Someone pressed a button, chose in a menu, ran one of your / commands, typed in an option that suggests answers, or used the player. Answer within 3 seconds with Create Interaction Response. No intent is needed.

payload GatewayInteractionCreateData · no intent

PLAYER_STATE_UPDATE
A music bot's player in a voice channel changed (active: false when it ended). To people who can see the channel.

payload APIPlayerState · intent GUILD_VOICE_STATES · tether only

GUILD_BOT_SETTINGS_UPDATE
What the server decided about a bot changed: its prefix, its reading rule, its player settings. To every member.

payload APIGuildBotSettings · intent GUILDS · tether only

THEATRE_SESSION_UPDATE
A film started or changed in a theatre, or ended (session: null).

payload GatewayTheatreSessionUpdateData · intent GUILD_VOICE_STATES · tether only

THEATRE_STATE_UPDATE
The film was played, paused or moved.

payload GatewayTheatreStateUpdateData · intent GUILD_VOICE_STATES · tether only

THEATRE_REACTION
Reactions on the film, grouped per emoji about every second.

payload GatewayTheatreReactionData · intent GUILD_VOICE_STATES · tether only

THEATRE_CONTROL
Someone with the controls pressed something; to the host's own session only.

payload GatewayTheatreControlData · intent GUILD_VOICE_STATES · people only · tether only

POST_STATE_UPDATE
A post that does things changed state. Reserved.

payload GatewayPostStateUpdateData · intent GUILD_MESSAGES · tether only

USER_GUILD_SETTINGS_UPDATE
Your notification settings for a server (or your DMs) changed.

payload APIUserGuildSettings · no intent · people only · tether only

DM_LAYOUT_UPDATE
Your pinned conversations and folders changed.

payload APIDmLayout · no intent · people only · tether only

RELATIONSHIP_ADD
A friend, request or block was added or changed.

payload GatewayRelationshipAddData · no intent · people only · tether only

RELATIONSHIP_REMOVE
A relationship ended.

payload GatewayRelationshipRemoveData · no intent · people only · tether only

BAN_APPEAL_UPDATE
A ban appeal was sent or answered. To people who may ban.

payload APIBanAppeal · intent GUILD_MODERATION · tether only

MY_BAN_UPDATE
A ban you are under was added or changed.

payload APIMyBan · no intent · people only · tether only

MY_BAN_REMOVE
A ban of yours is gone.

payload GatewayMyBanRemoveData · no intent · people only · tether only

CHANNEL_RECIPIENT_ADD
Someone was added to a group DM.

payload GatewayChannelRecipientData · no intent

CHANNEL_RECIPIENT_REMOVE
Someone left a group DM.

payload GatewayChannelRecipientData · no intent

CALL_CREATE
A call started in a DM or group DM, or one is going on when you connect.

payload GatewayCallCreateData · no intent · people only · tether only

CALL_UPDATE
The ringing list of a DM call changed.

payload GatewayCallUpdateData · no intent · people only · tether only

CALL_DELETE
A DM call ended.

payload GatewayCallDeleteData · no intent · people only · tether only

AUTO_MODERATION_RULE_CREATE
An auto-mod rule was made. To people who manage the server.

payload GatewayAutoModRuleData · intent AUTO_MODERATION_CONFIGURATION

AUTO_MODERATION_RULE_UPDATE
An auto-mod rule changed. To people who manage the server.

payload GatewayAutoModRuleData · intent AUTO_MODERATION_CONFIGURATION

AUTO_MODERATION_RULE_DELETE
An auto-mod rule was removed. To people who manage the server.

payload GatewayAutoModRuleData · intent AUTO_MODERATION_CONFIGURATION

AUTO_MODERATION_ACTION_EXECUTION
Auto-mod did something. Never carries the message text.

payload GatewayAutoModActionExecutionData · intent AUTO_MODERATION_EXECUTION

GUILD_AUTOMOD_SETTINGS_UPDATE
The server's auto-mod settings changed.

payload GatewayAutoModSettingsUpdateData · intent AUTO_MODERATION_CONFIGURATION · tether only

GUILD_MOD_CASE_CREATE
A moderation case was made. To people who may moderate members.

payload GatewayModCaseData · intent GUILD_MODERATION · tether only

GUILD_MOD_CASE_UPDATE
A moderation case changed (a warning removed).

payload GatewayModCaseData · intent GUILD_MODERATION · tether only

GUILD_WARNINGS_UPDATE
What warnings lead to changed.

payload GatewayWarningSettingsUpdateData · intent GUILD_MODERATION · tether only

GUILD_TRIGGER_CREATE
A trigger was made. To people who manage the server.

payload GatewayTriggerData · intent GUILDS · tether only

GUILD_TRIGGER_UPDATE
A trigger changed.

payload GatewayTriggerData · intent GUILDS · tether only

GUILD_TRIGGER_DELETE
A trigger was removed.

payload GatewayTriggerDeleteData · intent GUILDS · tether only

GUILD_TRIGGER_STATE_UPDATE
A trigger's number or list changed.

payload GatewayTriggerStateUpdateData · intent GUILDS · tether only

GUILD_LEVELS_UPDATE
The level settings changed. To every member.

payload GatewayLevelSettingsUpdateData · intent GUILDS · tether only

MEMBER_LEVEL_UPDATE
Your own level changed.

payload GatewayMemberLevelUpdateData · no intent · people only · tether only

GAME_INVITE_CREATE
A game invite was sent, by you or to you (grapple's invites scope). Only to app sessions holding invites.

payload GatewayGameInviteData · no intent · people only · tether only

GAME_INVITE_UPDATE
One of your game invites was seen, accepted, declined, cancelled or expired. Only to app sessions holding invites.

payload GatewayGameInviteData · no intent · people only · tether only

GAME_INVITE_PLAY
You pressed Play on a game invite in tether. Only to your own app sessions holding invites.

payload GatewayGameInvitePlayData · no intent · people only · tether only