Events
Gateway Events
Gateway Events
Below are common dispatch events you should handle in bots and integrations.
Dispatch packet anatomy
Gateway events are delivered inside a dispatch envelope:
{
"op": 0,
"t": "MESSAGE_CREATE",
"s": 42,
"d": {}
}Important fields:
t: event names: sequence number used for resumed: event payload
The events most bots need first
If you are building a normal moderation, utility, or automation bot, start with:
READYMESSAGE_CREATEMESSAGE_UPDATEMESSAGE_DELETEGUILD_CREATEGUILD_MEMBER_ADDGUILD_MEMBER_REMOVEINVITE_CREATEINVITE_DELETEVOICE_STATE_UPDATE
Session
READYRESUMEDSESSIONS_REPLACE
User and presence
USER_UPDATEUSER_SETTINGS_UPDATEUSER_GUILD_SETTINGS_UPDATEPRESENCE_UPDATEAUTH_SESSION_CHANGE
Guild
GUILD_CREATEGUILD_UPDATEGUILD_DELETEGUILD_MEMBER_ADDGUILD_MEMBER_UPDATEGUILD_MEMBER_REMOVEGUILD_ROLE_CREATEGUILD_ROLE_UPDATEGUILD_ROLE_UPDATE_BULKGUILD_ROLE_DELETEGUILD_BAN_ADDGUILD_BAN_REMOVEGUILD_MEMBERS_CHUNKGUILD_MEMBER_LIST_UPDATEGUILD_SYNC
Channel and invite
CHANNEL_CREATECHANNEL_UPDATECHANNEL_UPDATE_BULKCHANNEL_DELETECHANNEL_RECIPIENT_ADDCHANNEL_RECIPIENT_REMOVECHANNEL_PINS_UPDATECHANNEL_PINS_ACKINVITE_CREATEINVITE_DELETEWEBHOOKS_UPDATE
Messages
MESSAGE_CREATEMESSAGE_UPDATEMESSAGE_DELETEMESSAGE_DELETE_BULKMESSAGE_REACTION_ADDMESSAGE_REACTION_REMOVEMESSAGE_REACTION_REMOVE_ALLMESSAGE_REACTION_REMOVE_EMOJIMESSAGE_ACKTYPING_START
Typical MESSAGE_CREATE fields
Most bots care about:
idchannel_idguild_id?authorcontentattachmentsembedsreferenced_message?
Minimal example:
{
"id": "1470000000000000001",
"channel_id": "1470000000000000002",
"guild_id": "1470000000000000003",
"content": "!ping",
"author": {
"id": "1470000000000000004",
"username": "ice"
}
}Voice and calls
VOICE_STATE_UPDATEVOICE_SERVER_UPDATECALL_CREATECALL_UPDATECALL_DELETE
Voice events
The most important voice event for state tracking is usually VOICE_STATE_UPDATE.
Use it to detect:
- channel joins
- channel leaves
- mute/deaf changes
- active voice participation changes
Handling strategy
Good default pattern
- Use Gateway to detect the event
- Inspect
d - Decide what action to take
- Use REST to perform the action
Example:
- receive
MESSAGE_CREATE - if content is
!ping POST /channels/:channel_id/messages
Idempotency
Your handlers should tolerate reconnects and duplicate work safely:
- avoid assuming an event is seen only once
- guard state transitions carefully
- use message IDs and sequence numbers for deduplication if needed
Other
RELATIONSHIP_ADDRELATIONSHIP_UPDATERELATIONSHIP_REMOVEFAVORITE_MEME_CREATEFAVORITE_MEME_UPDATEFAVORITE_MEME_DELETEPASSIVE_UPDATES
Event casing
Event names are uppercase strings (for example MESSAGE_CREATE, VOICE_STATE_UPDATE).