Event filtering
Squad has no gateway intents. Identify ignores an intents field, and a client ported from Discord gets the events described here once it connects with v=1. You limit Dispatch traffic with Lazy Request subscriptions, the Identify ignored_events list and the CHANNEL_THREADS session flag.
Permission and visibility
Заголовок раздела «Permission and visibility»Squad sends each guild event to the sessions in the Recipients column. A session that is still connecting to the guild gets none of them.
| Event class | Recipients |
|---|---|
| Channel create, update and delete, Message Create, Message Delete Bulk, Typing Start, Channel Pins Update, Webhooks Update | Sessions that can view the channel |
| Message Update, Message Delete and the reaction events | Sessions that can view the channel and access the message |
| Invite Create and Invite Delete | Sessions with MANAGE_CHANNELS on the invite’s channel |
| Guild Audit Log Entry Create | Sessions with VIEW_AUDIT_LOG. Entries about threads need thread access. |
| Voice State Update | Sessions that can view the voice state’s channel or the channel the user left |
| Thread events | Listed for each event on Gateway threads |
| Everything else | Every session connected to the guild |
A session can view a channel when it has VIEW_CHANNEL, and it can view a category when it can view one of the category’s channels. A user in a voice channel can still view it until they leave, even after a permission change that would hide it.
A session can access a message when it has READ_MESSAGE_HISTORY or when the message is newer than the guild’s message history cutoff.
Channel Update Bulk has only the channels the session can view.
When you pass the session_id query parameter to Add own reaction, Remove own reaction or Remove another user’s reaction in a guild channel, that session gets no Message Reaction Add or Message Reaction Remove for the change. In a private channel the session still gets the event, with session_id set.
A guild with the UNAVAILABLE_FOR_EVERYONE or UNAVAILABLE_FOR_EVERYONE_BUT_STAFF feature sends only Guild Update.
Active and passive guilds
Заголовок раздела «Active and passive guilds»In a guild with more than 250 members, a user session is passive until a Lazy Request sets active: true for that guild. The guild in Identify initial_guild_id starts active, and bot sessions are never passive.
A passive session in a larger guild gets only these events.
- Guild Update and Guild Delete
- Guild Role Update and Guild Role Update Bulk
- Channel Create, Channel Update, Channel Update Bulk and Channel Delete
- Guild Audit Log Entry Create
- Message Create and Message Update for a message that mentions the session’s user, and Message Create for the user’s own messages
- Guild Member Update and Guild Member Remove for the session’s own user
- The thread events marked for passive sessions
- Passive Updates
A message mentions the user when mentions has the user, mention_roles has one of the user’s roles, or mention_here or mention_everyone is set.
Passive Updates comes every 30 seconds with the changed last_message_id values and voice states for channels the session can view, and Squad skips it when nothing changed. A passive session gets voice state changes only this way.
Typing is decided separately
Заголовок раздела «Typing is decided separately»When you set typing for a guild in Lazy Request, that value alone decides whether the session gets Typing Start, including for bots. Without it the event follows the active state.
Events in a thread
Заголовок раздела «Events in a thread»A message, reaction, typing or pin event in a thread also has to meet one of the conditions on Gateway threads. The threads condition applies only while the guild is active for the session.
Member lists
Заголовок раздела «Member lists»Guild Member List Update goes to a session only for a channel in its member_list_channels that it can view with VIEW_CHANNEL_MEMBERS. A session has one member list subscription at a time. Subscribing a channel in one guild drops the member list it had in any other channel or guild.
Visited guilds
Заголовок раздела «Visited guilds»A session visiting a guild gets only these events for that guild.
- Guild Update and the role, emoji and sticker events
- Channel create, update and delete events for channels a visitor can read, with only the @everyone overwrite
- Channel Pins Update for channels a visitor can read
- Message and reaction events for the channel set as
focused_channel_idin Lazy Request - Thread create, update and delete events for public threads in channels that the visitor is allowed to read
Visitors never appear in member lists, presences, typing, voice states or member counts. Squad ignores member list ranges, Request Guild Members, read acknowledgements and typing from a session for a visited guild.
Presence subscriptions
Заголовок раздела «Presence subscriptions»A session gets a Presence Update for a guild member only if it listed that user in the members array of a Lazy Request and can view a channel the user can view. Each members array replaces the previous set for that guild. If the session loses access to every channel it shares with a user, send that user in members again after access returns.
Ignored events
Заголовок раздела «Ignored events»ignored_events in Identify is an array of up to 256 Dispatch event names. Squad drops each listed event for the session, and the list can only change with a new Identify. An invalid value closes the connection with 4002.
Squad still sends Message Create when MESSAGE_CREATE is ignored if the message mentions the user directly or uses @here or @everyone, but not for a role mention. A dropped event uses no sequence number.
{ "op": 2, "d": { "token": "...", "properties": {"os": "Linux", "browser": "bot", "device": "bot"}, "ignored_events": ["TYPING_START", "PRESENCE_UPDATE"] }}The shard filter
Заголовок раздела «The shard filter»A session that identified with a shard_id other than 0 drops every Dispatch that has no guild. This filter does not drop Rate Limited, Guild Counts Update or Channel Member Counts Update, which are replies to a command the session sent. Account, direct message, relationship and call events arrive only on shard 0 or on a session that sent no shard pair.
What a bot should send
Заголовок раздела «What a bot should send»A bot needs no Lazy Request, and if it doesn’t use typing or reactions, add TYPING_START, MESSAGE_REACTION_ADD and MESSAGE_REACTION_REMOVE to ignored_events.