GatewayIntent
Flags which enable or disable specific events from the Discord gateway. Gateway intents allow you to control which events your bot receives, reducing bandwidth and improving performance.Overview
Gateway intents are used to subscribe to specific categories of events. Some intents are privileged and require approval from Discord or enabling in your application’s developer dashboard.Privileged Intents
The following intents are privileged and require special approval:GUILD_MEMBERS- Member join/leave/update eventsGUILD_PRESENCES- Presence and online status updatesMESSAGE_CONTENT- Access to message content data
Intent Constants
GUILD_MEMBERS
PRIVILEGED INTENT - Events for member updates, joins, and leaves. Required to chunk all members of a guild. Without this enabled, you must useChunkingFilter.NONE. Also updates user information such as username and avatar.
Offset: 1
GUILD_MODERATION
Moderation events such as bans, unbans, and audit logs. Offset: 2 Events:- Guild ban/unban events
- Audit log entry creation
GUILD_EXPRESSIONS
Custom emoji, sticker, and soundboard sound add/update/delete events. Offset: 3 Events:- Emoji created/updated/deleted
- Sticker created/updated/deleted
- Soundboard sounds modified
GUILD_WEBHOOKS
Webhook events for creation, update, and deletion. Offset: 5 Events:- Webhook created/updated/deleted
GUILD_INVITES
Invite events for creation and deletion. Offset: 6 Events:- Invite created
- Invite deleted
GUILD_VOICE_STATES
Voice state events. Required to get information about members in voice channels and to connect to voice channels. Offset: 7 Important: You cannot connect to a voice channel without this intent. Events:- Voice state updates
- Members joining/leaving voice channels
GUILD_PRESENCES
PRIVILEGED INTENT - Presence updates including online status and activities. Offset: 8 This is a very heavy intent as presence updates constitute ~99% of gateway traffic. Used primarily to trackMember.getOnlineStatus() and Member.getActivities().
Consider using GUILD_MEMBERS instead if you only need user updates.
GUILD_MESSAGES
Message events from text channels in guilds. Most bots need this for commands. Offset: 9 Events:- Message created/updated/deleted in guild channels
- Bulk message deletion
GUILD_MESSAGE_REACTIONS
Message reaction events in guilds. Useful for reaction roles and paginated embeds. Offset: 10 Events:- Reactions added/removed in guild channels
GUILD_MESSAGE_TYPING
Typing start events in guilds. Rarely used by bots. Offset: 11 Events:- User starts typing in guild channels
DIRECT_MESSAGES
Message events in private channels (DMs). You can still send DMs without this intent. Offset: 12 Events:- DM messages created/updated/deleted
DIRECT_MESSAGE_REACTIONS
Message reaction events in private channels. Offset: 13 Events:- Reactions added/removed in DMs
DIRECT_MESSAGE_TYPING
Typing start events in private channels. Rarely used by bots. Offset: 14 Events:- User starts typing in DMs
MESSAGE_CONTENT
PRIVILEGED INTENT - Access to message content. Affects messages received through message history or message events. Does not apply to:- Messages that mention the bot directly
- Messages sent by the bot itself
- Direct messages in private channels
Message.getContentRaw(),getContentDisplay(),getContentStripped()Message.getEmbeds()Message.getAttachments()Message.getComponents(),getComponentTree()
SCHEDULED_EVENTS
Scheduled event tracking in guilds. Offset: 16 Events:- Scheduled events created/updated/deleted
- User subscriptions to scheduled events
AUTO_MODERATION_CONFIGURATION
Auto-moderation rule changes. Offset: 20 Events:- Auto-mod rules created/updated/deleted
AUTO_MODERATION_EXECUTION
Auto-moderation response action events. Offset: 21 Events:- Auto-mod actions executed
GUILD_MESSAGE_POLLS
Poll vote events in guilds. Offset: 24 Events:- Poll votes in guild channels
DIRECT_MESSAGE_POLLS
Poll vote events in private channels. Offset: 25 Events:- Poll votes in DMs
Methods
getRawValue()
Returns the raw bitmask value for this intent. Returns: The raw bitmask valuegetOffset()
Returns the offset of the intent flag within a bitmask. Returns: The bit offset (wheregetRawValue() == 1 << getOffset())
Static Methods
getIntents(int raw)
Converts a bitmask into an EnumSet of intents. Parameters:raw- The raw bitmask
getRaw(Collection<GatewayIntent> set)
Converts a collection of intents to a bitmask. Parameters:set- The collection of intents
getRaw(GatewayIntent intent, GatewayIntent… set)
Converts intents to a bitmask. Parameters:intent- The first intentset- Additional intents
fromCacheFlags(CacheFlag flag, CacheFlag… other)
Parses required intents from cache flags. Parameters:flag- The first cache flagother- Additional cache flags
fromCacheFlags(Collection<CacheFlag> flags)
Parses required intents from a collection of cache flags. Parameters:flags- The cache flags
fromEvents(Class<? extends GenericEvent>… events)
Parses required intents from event types. Parameters:events- The event classes
fromEvents(Collection<Class<? extends GenericEvent>> events)
Parses required intents from a collection of event types. Parameters:events- The event classes
from(Collection<Class<? extends GenericEvent>> events, Collection<CacheFlag> flags)
Parses required intents from both event types and cache flags. Parameters:events- The event classesflags- The cache flags
Constants
ALL_INTENTS
Bitmask with all intents enabled.EnumSet.allOf(GatewayIntent.class).
DEFAULT
Recommended default intents with privileged and rarely-used intents disabled: Excluded:GUILD_MEMBERS(privileged)GUILD_PRESENCES(privileged)MESSAGE_CONTENT(privileged)GUILD_WEBHOOKS(not useful for most bots)GUILD_MESSAGE_TYPING(not useful for most bots)DIRECT_MESSAGE_TYPING(not useful for most bots)
Usage Examples
Basic Bot with Default Intents
Enabling Privileged Intents
Minimal Bot (Light Mode)
Custom Intent Configuration
Voice-Enabled Bot
Auto-detecting Intents from Events
Important Notes
-
Chunking Requirement: You must use
ChunkingFilter.NONEifGUILD_MEMBERSis disabled. -
Privileged Intents: To use privileged intents, you must:
- Enable them in your Discord application dashboard
- If your bot is in 100+ servers, request verification from Discord
-
Performance: Disable unused intents to reduce bandwidth and improve performance, especially
GUILD_PRESENCESwhich generates significant traffic. -
Voice Connections:
GUILD_VOICE_STATESis mandatory for voice functionality.