Перейти к содержимому

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.

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 classRecipients
Channel create, update and delete, Message Create, Message Delete Bulk, Typing Start, Channel Pins Update, Webhooks UpdateSessions that can view the channel
Message Update, Message Delete and the reaction eventsSessions that can view the channel and access the message
Invite Create and Invite DeleteSessions with MANAGE_CHANNELS on the invite’s channel
Guild Audit Log Entry CreateSessions with VIEW_AUDIT_LOG. Entries about threads need thread access.
Voice State UpdateSessions that can view the voice state’s channel or the channel the user left
Thread eventsListed for each event on Gateway threads
Everything elseEvery 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.

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.

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.

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.

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.

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.

A session visiting a guild gets only these events for that guild.

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.

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 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"]
}
}

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.

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.