- Send events are Gateway events sent by an app to Discord (like when identifying with the Gateway)
- Receive events are Gateway events that are sent by Discord to an app. These events typically represent something happening inside of a server where an app is installed, like a channel being updated.
Event Names
In practice, event names are UPPER-CASED with under_scores joining each word in the name. For instance, Channel Create would beCHANNEL_CREATE and Voice State Update would be VOICE_STATE_UPDATE.
For readability, event names in the following documentation are typically left in Title Case.
Payload Structure
Gateway event payloads have a common structure, but the contents of the associated data (d) varies between the different events.
*
s and t are null when op is not 0 (Gateway Dispatch opcode).
Example Gateway Event Payload
Send Events
Send events are Gateway events encapsulated in an event payload, and are sent by an app to Discord through a Gateway connection.Previously, Gateway send events were labeled as commands
Identify
Used to trigger the initial handshake with the gateway. Details about identifying is in the Gateway documentation.Identify Structure
Identify Connection Properties
Example Identify
Resume
Used to replay missed events when a disconnected client resumes. Details about resuming are in the Gateway documentation.Resume Structure
Example Resume
Heartbeat
Used to maintain an active gateway connection. Must be sent everyheartbeat_interval milliseconds after the Opcode 10 Hello payload is received. The inner d key is the last sequence number—s—received by the client. If you have not yet received one, send null.
Details about heartbeats are in the Gateway documentation.
Example Heartbeat
Request Guild Members
Used to request all members for a guild or a list of guilds. When initially connecting, if you don’t have theGUILD_PRESENCES Gateway Intent, or if the guild is over 75k members, it will only send members who are in voice, plus the member for you (the connecting user). Otherwise, if a guild has over large_threshold members (value in the Gateway Identify), it will only send members who are online, have a role, have a nickname, or are in a voice channel, and if it has under large_threshold members, it will send all members. If a client wishes to receive additional members, they need to explicitly request them via this operation. The server will send Guild Members Chunk events in response with up to 1000 members per chunk until all members that match the request have been sent.
Due to our privacy and infrastructural concerns with this feature, there are some limitations that apply:
GUILD_PRESENCESintent is required to setpresences = true. Otherwise, it will always be falseGUILD_MEMBERSintent is required to request the entire member list—(query=‘’, limit=0<=n)- You will be limited to requesting 1
guild_idper request - Requesting a prefix (
queryparameter) will return a maximum of 100 members - Requesting
user_idswill continue to be limited to returning 100 members
We are introducing a new rate limit to the Request Guild Members opcode. See Introducing Rate Limit When Requesting All Guild Members for more information and timeline on this new rate limit.
Request Guild Members Structure
Nonce can only be up to 32 bytes. If you send an invalid nonce it will be ignored and the reply member_chunk(s) will not have a nonce set.
Example Request Guild Members
Request Soundboard Sounds
Used to request soundboard sounds for a list of guilds. The server will send Soundboard Sounds events for each guild in response.Request Soundboard Sounds Structure
Example Request Soundboard Sounds
Update Voice State
Sent when a client wants to join, move, or disconnect from a voice channel.Gateway Voice State Update Structure
Example Gateway Voice State Update
Update Presence
Sent by the client to indicate a presence or status update.Gateway Presence Update Structure
Status Types
Example Gateway Presence Update
Receive Events
Receive events are Gateway events encapsulated in an event payload, and are sent by Discord to an app through a Gateway connection. Receive events correspond to events that happen in a Discord server where the app is installed.Hello
Sent on connection to the websocket. Defines the heartbeat interval that an app should heartbeat to.Hello Structure
Example Hello
Ready
The ready event is dispatched when a client has completed the initial handshake with the gateway (for new sessions). The ready event can be the largest and most complex event the gateway will send, as it contains all the state required for a client to begin interacting with the rest of the platform.guilds are the guilds of which your bot is a member. They start out as unavailable when you connect to the gateway. As they become available, your bot will be notified via Guild Create events.
Ready Event Fields
Resumed
The resumed event is dispatched when a client has sent a resume payload to the gateway (for resuming existing sessions).Reconnect
The reconnect event is dispatched when a client should reconnect to the gateway (and resume their existing session, if they have one). This can occur at any point in the gateway connection lifecycle, even before/in place of receiving a Hello event. A few seconds after the reconnect event is dispatched, the connection may be closed by the server.Example Gateway Reconnect
Invalid Session
Sent to indicate one of at least three different situations:- the gateway could not initialize a session after receiving an Opcode 2 Identify
- the gateway could not resume a previous session after receiving an Opcode 6 Resume
- the gateway has invalidated an active session and is requesting client action
d key is a boolean that indicates whether the session may be resumable. See Connecting and Resuming for more information.
Example Gateway Invalid Session
Application Commands
Application Command Permissions Update
APPLICATION_COMMAND_PERMISSIONS_UPDATE event, sent when an application command’s permissions are updated. The inner payload is an application command permissions object.
Auto Moderation
All Auto Moderation related events are only sent to bot users which have theMANAGE_GUILD permission.
Auto Moderation Rule Create
Sent when a rule is created. The inner payload is an auto moderation rule object.Auto Moderation Rule Update
Sent when a rule is updated. The inner payload is an auto moderation rule object.Auto Moderation Rule Delete
Sent when a rule is deleted. The inner payload is an auto moderation rule object.Auto Moderation Action Execution
Sent when a rule is triggered and an action is executed (e.g. when a message is blocked).Auto Moderation Action Execution Event Fields
*
message_id will not exist if message was blocked by Auto Moderation or content was not part of any message
** alert_system_message_id will not exist if this event does not correspond to an action with type SEND_ALERT_MESSAGE
*** MESSAGE_CONTENT (1 << 15) gateway intent is required to receive the content and matched_content fields
Channels
Channel Create
Sent when a new guild channel is created, relevant to the current user. The inner payload is a channel object.Channel Update
Sent when a channel is updated. The inner payload is a channel object. This is not sent when the fieldlast_message_id is altered. To keep track of the last_message_id changes, you must listen for Message Create events (or Thread Create events for GUILD_FORUM and GUILD_MEDIA channels).
This event may reference roles or guild members that no longer exist in the guild.
Channel Delete
Sent when a channel relevant to the current user is deleted. The inner payload is a channel object.Thread Create
Sent when a thread is created, relevant to the current user, or when the current user is added to a thread. The inner payload is a channel object.- When a thread is created, includes an additional
newly_createdboolean field. - When being added to an existing private thread, includes a thread member object.
Thread Update
Sent when a thread is updated. The inner payload is a channel object. This is not sent when the fieldlast_message_id is altered. To keep track of the last_message_id changes, you must listen for Message Create events.
Thread Delete
Sent when a thread relevant to the current user is deleted. The inner payload is a subset of the channel object, containing just theid, guild_id, parent_id, and type fields.
Thread List Sync
Sent when the current user gains access to a channel.Thread List Sync Event Fields
Thread Member Update
Sent when the thread member object for the current user is updated. The inner payload is a thread member object with an extraguild_id field. This event is documented for completeness, but unlikely to be used by most bots. For bots, this event largely is just a signal that you are a member of the thread. See the threads docs for more details.
Thread Member Update Event Extra Fields
Thread Members Update
Sent when anyone is added to or removed from a thread. If the current user does not have theGUILD_MEMBERS Gateway Intent, then this event will only be sent if the current user was added to or removed from the thread.
Thread Members Update Event Fields
* In this gateway event, the thread member objects will also include the guild member and nullable presence objects for each added thread member.
Channel Pins Update
Sent when a message is pinned or unpinned in a text channel. This is not sent when a pinned message is deleted.Channel Pins Update Event Fields
Entitlements
Entitlement Create
Sent when an entitlement is created. The inner payload is an entitlement object.Entitlement Update
Sent when an entitlement is updated. The inner payload is an entitlement object. For subscription entitlements, this event is triggered only when a user’s subscription ends, providing anends_at timestamp that indicates the end of the entitlement.
Entitlement Delete
Sent when an entitlement is deleted. The inner payload is an entitlement object. Entitlement deletions are infrequent, and occur when:- Discord issues a refund for a subscription
- Discord removes an entitlement from a user via internal tooling
- Discord deletes an app-managed entitlement they created via the API
Guilds
Guild Create
This event can be sent in three different scenarios:- When a user is initially connecting, to lazily load and backfill information for all unavailable guilds sent in the Ready event. Guilds that are unavailable due to an outage will send a Guild Delete event.
- When a Guild becomes available again to the client.
- When the current user joins a new Guild.
During an outage, the guild object in scenarios 1 and 3 may be marked as unavailable.
- An available Guild: a guild object with extra fields, as noted below.
- An unavailable Guild: an unavailable guild object.
Guild Create Extra Fields
Guild Update
Sent when a guild is updated. The inner payload is a guild object.Guild Delete
Sent when a guild becomes or was already unavailable due to an outage, or when the user leaves or is removed from a guild. The inner payload is an unavailable guild object. If theunavailable field is not set, the user was removed from the guild.
Guild Audit Log Entry Create
Sent when a guild audit log entry is created. The inner payload is an Audit Log Entry object with an extraguild_id key. This event is only sent to bots with the VIEW_AUDIT_LOG permission.
Guild Audit Log Entry Create Event Extra Fields
Guild Ban Add
Sent when a user is banned from a guild. This event is only sent to bots with theBAN_MEMBERS or VIEW_AUDIT_LOG permission.
Guild Ban Add Event Fields
Guild Ban Remove
Sent when a user is unbanned from a guild. This event is only sent to bots with theBAN_MEMBERS or VIEW_AUDIT_LOG permission.
Guild Ban Remove Event Fields
Guild Emojis Update
Sent when a guild’s emojis have been updated.Guild Emojis Update Event Fields
Guild Stickers Update
Sent when a guild’s stickers have been updated.Guild Stickers Update Event Fields
Guild Integrations Update
Sent when a guild integration is updated.Guild Integrations Update Event Fields
Guild Member Add
Sent when a new user joins a guild. The inner payload is a guild member object with an extraguild_id key:
Guild Member Add Extra Fields
Guild Member Remove
Sent when a user is removed from a guild (leave/kick/ban).Guild Member Remove Event Fields
Guild Member Update
Sent when a guild member is updated. This will also fire when the user object of a guild member changes.Guild Member Update Event Fields
Guild Members Chunk
Sent in response to Guild Request Members. You can use thechunk_index and chunk_count to calculate how many chunks are left for your request.
Guild Members Chunk Event Fields
Guild Role Create
Sent when a guild role is created.Guild Role Create Event Fields
Guild Role Update
Sent when a guild role is updated.Guild Role Update Event Fields
Guild Role Delete
Sent when a guild role is deleted.Guild Role Delete Event Fields
Guild Scheduled Event Create
Sent when a guild scheduled event is created. The inner payload is a guild scheduled event object.Guild Scheduled Event Update
Sent when a guild scheduled event is updated. The inner payload is a guild scheduled event object.Guild Scheduled Event Delete
Sent when a guild scheduled event is deleted. The inner payload is a guild scheduled event object.Guild Scheduled Event User Add
Sent when a user has subscribed to a guild scheduled event.Guild Scheduled Event User Add Event Fields
Guild Scheduled Event User Remove
Sent when a user has unsubscribed from a guild scheduled event.Guild Scheduled Event User Remove Event Fields
Guild Soundboard Sound Create
Sent when a guild soundboard sound is created. The inner payload is a soundboard sound object.Guild Soundboard Sound Update
Sent when a guild soundboard sound is updated. The inner payload is a soundboard sound object.Guild Soundboard Sound Delete
Sent when a guild soundboard sound is deleted.Guild Soundboard Sound Delete Event Fields
Guild Soundboard Sounds Update
Sent when multiple guild soundboard sounds are updated.Guild Soundboard Sounds Update Event Fields
Soundboard Sounds
Includes a guild’s list of soundboard sounds. Sent in response to Request Soundboard Sounds.Soundboard Sounds Event Fields
Integrations
Integration Create
Sent when an integration is created. The inner payload is an integration object withuser omitted and an additional guild_id key:
Integration Create Event Additional Fields
Integration Update
Sent when an integration is updated. The inner payload is an integration object withuser omitted and an additional guild_id key:
Integration Update Event Additional Fields
Integration Delete
Sent when an integration is deleted.Integration Delete Event Fields
Invites
All Invite related events are only sent to bot users with theMANAGE_CHANNELS permission on the channel.
Invite Create
Sent when a new invite to a channel is created.Invite Create Event Fields
Invite Delete
Sent when an invite is deleted.Invite Delete Event Fields
Messages
Message Create
Sent when a message is created. The inner payload is a message object with the following extra fields:Message Create Extra Fields
Message Update
Sent when a message is updated. The inner payload is a message object with the same extra fields as MESSAGE_CREATE.Message Delete
Sent when a message is deleted.Message Delete Event Fields
Message Delete Bulk
Sent when multiple messages are deleted at once.Message Delete Bulk Event Fields
Message Reaction Add
Sent when a user adds a reaction to a message.Message Reaction Add Event Fields
Message Reaction Remove
Sent when a user removes a reaction from a message.Message Reaction Remove Event Fields
Message Reaction Remove All
Sent when a user explicitly removes all reactions from a message.Message Reaction Remove All Event Fields
Message Reaction Remove Emoji
Sent when a bot removes all instances of a given emoji from the reactions of a message.Message Reaction Remove Emoji Event Fields
Presence
Presence Update
A user’s presence is their current state on a guild. This event is sent when a user’s presence or info, such as name or avatar, is updated.Presence Update Event Fields
Client Status Object
Active sessions are indicated with an “online”, “idle”, or “dnd” string per platform. If a user is offline or invisible, the corresponding field is not present.Activity Object
Activity Structure
Bot users are only able to set
name, state, type, and url.Activity Types
The streaming type currently only supports Twitch and YouTube. Only
https://twitch.tv/ and https://youtube.com/ urls will work.Status Display Types
This applies to all activity types. “Listening” was used to serve as a consistent example of what the different fields might be used for.
Activity Timestamps
For Listening and Watching activities, you can include both start and end timestamps to display a time bar.
Activity Emoji
Activity Party
Activity Assets
Activity Asset Image
Activity asset images are arbitrary strings which usually contain snowflake IDs or prefixed image IDs. Treat data within this field carefully, as it is user-specifiable and not sanitized. To use an external image via media proxy, specify the URL as the field’s value when sending. You will only receive themp: prefix via the gateway.
Uploaded assets (Application Asset type) support PNG, JPEG, and WebP. Animated images are not supported for uploaded assets.External URL assets (Media Proxy Image type) support any publicly accessible image URL, including GIF, animated WebP, and AVIF.
Activity Secrets
Activity Flags
Activity Buttons
When received over the gateway, thebuttons field is an array of strings, which are the button labels. Bots cannot access a user’s activity button URLs. When sending, the buttons field must be an array of the below object:
Example Activity
Example Activity with Rich Presence
Typing Start
Sent when a user starts typing in a channel.Typing Start Event Fields
User Update
Sent when properties about the current bot’s user change. Inner payload is a user object.Voice
Voice Channel Effect Send
Sent when someone sends an effect, such as an emoji reaction or a soundboard sound, in a voice channel the current user is connected to.Voice Channel Effect Send Event Fields
Animation Types
Voice State Update
Sent when someone joins/leaves/moves voice channels. Inner payload is a voice state object.Voice Server Update
Sent when a guild’s voice server is updated. This is sent when initially connecting to voice, and when the current voice instance fails over to a new server.Voice Server Update Event Fields
Example Voice Server Update Payload
Webhooks
Webhooks Update
Sent when a guild channel’s webhook is created, updated, or deleted.Webhooks Update Event Fields
Interactions
Interaction Create
Sent when a user uses an Application Command or Message Component. Inner payload is an Interaction.Stage Instances
Stage Instance Create
Sent when a Stage instance is created (i.e. the Stage is now “live”). Inner payload is a Stage instanceStage Instance Update
Sent when a Stage instance has been updated. Inner payload is a Stage instanceStage Instance Delete
Sent when a Stage instance has been deleted (i.e. the Stage has been closed). Inner payload is a Stage instanceSubscriptions
Subscription Create
Subscription status should not be used to grant perks. Use entitlements as an indication of whether a user should have access to a specific SKU. See our guide on Implementing App Subscriptions for more information.
status can be either inactive or active when this event is received. You will receive subsequent SUBSCRIPTION_UPDATE events if the status is updated to active. As a best practice, you should not grant any perks to users until the entitlements are created.
Subscription Update
Sent when a Subscription for a Premium App has been updated. Inner payload is a Subscription object.Subscription Delete
Sent when a Subscription for a Premium App has been deleted. Inner payload is a Subscription object.Polls
Message Poll Vote Add
Sent when a user votes on a poll. If the poll allows multiple selection, one event will be sent per answer.Message Poll Vote Add Fields
Message Poll Vote Remove
Sent when a user removes their vote on a poll. If the poll allows for multiple selections, one event will be sent per answer.Message Poll Vote Remove Fields
Rate Limits
Rate Limited
Sent when an app encounters a gateway rate limit for an event, such as Request Guild Members.See changelog for Introducing Rate Limit When Requesting All Guild Members for more information and timeline on this new rate limit.