Package net.dv8tion.jda.api.requests
Enum GatewayIntent
- java.lang.Object
-
- java.lang.Enum<GatewayIntent>
-
- net.dv8tion.jda.api.requests.GatewayIntent
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<GatewayIntent>
public enum GatewayIntent extends java.lang.Enum<GatewayIntent>
Flags which enable or disable specific events from the discord gateway.The way to use these is very simple. Go through each intent in the following list and decide whether your bot will need these events or not.
- GUILD_MEMBERS - This is a privileged gateway intent that is used to update user information and join/leaves (including kicks). This is required to cache all members of a guild (including chunking)
- GUILD_BANS - This will only track guild bans and unbans
- GUILD_EMOJIS - This will only track guild emote create/modify/delete. Most bots don't need this since they just use the emote id anyway.
- GUILD_WEBHOOKS - This will only track guild webhook create/update/delete. Most bots don't need this since related events don't contain any useful information about webhook changes.
- GUILD_INVITES - This will only track invite create/delete. Most bots don't make use of invites since they are added through OAuth2 authorization by administrators.
- GUILD_VOICE_STATES - Required to properly get information of members in voice channels and cache them. You cannot connect to a voice channel without this intent.
- GUILD_PRESENCES - This is a privileged gateway intent this is only used to track activity and online-status of a user.
- GUILD_MESSAGES - This is used to receive incoming messages in guilds (servers), most bots will need this for commands.
- GUILD_MESSAGE_REACTIONS - This is used to track reactions on messages in guilds (servers). Can be useful to make a paginated embed or reaction role management.
- GUILD_MESSAGE_TYPING - This is used to track when a user starts typing in guilds (servers). Almost no bot will have a use for this.
- DIRECT_MESSAGES - This is used to receive incoming messages in private channels (DMs). You can still send private messages without this intent.
- DIRECT_MESSAGE_REACTIONS - This is used to track reactions on messages in private channels (DMs).
- DIRECT_MESSAGE_TYPING - This is used to track when a user starts typing in private channels (DMs). Almost no bot will have a use for this.
You must use
ChunkingFilter.NONE
ifGUILD_MEMBERS
is disabled. To enable chunking the discord api requires the privilegedGUILD_MEMBERS
intent.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description DIRECT_MESSAGE_REACTIONS
Message reaction events in private channels.DIRECT_MESSAGE_TYPING
Typing events in private channels.DIRECT_MESSAGES
Message events in private channels.GUILD_BANS
Ban events.GUILD_EMOJIS
Emote add/update/delete events.GUILD_INVITES
Invite events.GUILD_MEMBERS
PRIVILEGED INTENT Events which inform us about member update/leave/join of a guild.GUILD_MESSAGE_REACTIONS
Message reaction events in guilds.GUILD_MESSAGE_TYPING
Typing start events in guilds.GUILD_MESSAGES
Message events from text channels in guilds.GUILD_PRESENCES
PRIVILEGED INTENT Presence updates.GUILD_VOICE_STATES
Voice state events.GUILD_WEBHOOKS
Webhook events.
-
Field Summary
Fields Modifier and Type Field Description static int
ALL_INTENTS
Bitmask with all intents enabled.static int
DEFAULT
All intents with some disabled: GUILD_MEMBERS (because its privileged) GUILD_PRESENCES (because its privileged) GUILD_WEBHOOKS because its not useful for most bots GUILD_MESSAGE_TYPING because its not useful for most bots DIRECT_MESSAGE_TYPING because its not useful for most bots To use these intents you have to pass no other intents tocreateLight(token)
orcreateDefault(token)
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.util.EnumSet<GatewayIntent>
from(java.util.Collection<java.lang.Class<? extends GenericEvent>> events, java.util.Collection<CacheFlag> flags)
Parse the required GatewayIntents from the providedEvent Types
andCacheFlags
.static java.util.EnumSet<GatewayIntent>
fromCacheFlags(java.util.Collection<CacheFlag> flags)
Parse the required GatewayIntents from the providedCacheFlags
.static java.util.EnumSet<GatewayIntent>
fromCacheFlags(CacheFlag flag, CacheFlag... other)
Parse the required GatewayIntents from the providedCacheFlags
.static java.util.EnumSet<GatewayIntent>
fromEvents(java.lang.Class<? extends GenericEvent>... events)
Parse the required GatewayIntents from the providedEvent Types
.static java.util.EnumSet<GatewayIntent>
fromEvents(java.util.Collection<java.lang.Class<? extends GenericEvent>> events)
Parse the required GatewayIntents from the providedEvent Types
.static java.util.EnumSet<GatewayIntent>
getIntents(int raw)
Converts a bitmask into anEnumSet
of enum values.int
getOffset()
The offset of the intent flag within a bitmask
This meansgetRawValue() == 1 << getOffset()
static int
getRaw(java.util.Collection<GatewayIntent> set)
Converts the given intents to a bitmaskstatic int
getRaw(GatewayIntent intent, GatewayIntent... set)
Converts the given intents to a bitmaskint
getRawValue()
The raw bitmask value for this intentstatic GatewayIntent
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static GatewayIntent[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
GUILD_MEMBERS
public static final GatewayIntent GUILD_MEMBERS
PRIVILEGED INTENT Events which inform us about member update/leave/join of a guild.
This is required to chunk all members of a guild. Without this enabled you have to useChunkingFilter.NONE
!This will also update user information such as name/avatar.
-
GUILD_BANS
public static final GatewayIntent GUILD_BANS
Ban events.
-
GUILD_EMOJIS
public static final GatewayIntent GUILD_EMOJIS
Emote add/update/delete events.
-
GUILD_WEBHOOKS
public static final GatewayIntent GUILD_WEBHOOKS
Webhook events.
-
GUILD_INVITES
public static final GatewayIntent GUILD_INVITES
Invite events.
-
GUILD_VOICE_STATES
public static final GatewayIntent GUILD_VOICE_STATES
Voice state events. This is used to determine which members are connected to a voice channel.
-
GUILD_PRESENCES
public static final GatewayIntent GUILD_PRESENCES
PRIVILEGED INTENT Presence updates. This is used to lazy load members and update user properties such as name/avatar.
This is a very heavy intent! Presence updates are 99% of traffic the bot will receive. To get user update events you should consider usingGUILD_MEMBERS
instead.This intent is primarily used to track
Member.getOnlineStatus()
andMember.getActivities()
.
-
GUILD_MESSAGES
public static final GatewayIntent GUILD_MESSAGES
Message events from text channels in guilds.
-
GUILD_MESSAGE_REACTIONS
public static final GatewayIntent GUILD_MESSAGE_REACTIONS
Message reaction events in guilds.
-
GUILD_MESSAGE_TYPING
public static final GatewayIntent GUILD_MESSAGE_TYPING
Typing start events in guilds.
-
DIRECT_MESSAGES
public static final GatewayIntent DIRECT_MESSAGES
Message events in private channels.
-
DIRECT_MESSAGE_REACTIONS
public static final GatewayIntent DIRECT_MESSAGE_REACTIONS
Message reaction events in private channels.
-
DIRECT_MESSAGE_TYPING
public static final GatewayIntent DIRECT_MESSAGE_TYPING
Typing events in private channels.
-
-
Field Detail
-
ALL_INTENTS
public static final int ALL_INTENTS
Bitmask with all intents enabled.To use all intents in your own code you should use
EnumSet.allOf(GatewayIntent.class)
instead. This value only represents the raw bitmask used in JDA.
You can useEnumSet.noneOf(GatewayIntent.class)
to achieve the opposite.
-
DEFAULT
public static final int DEFAULT
All intents with some disabled:- GUILD_MEMBERS (because its privileged)
- GUILD_PRESENCES (because its privileged)
- GUILD_WEBHOOKS because its not useful for most bots
- GUILD_MESSAGE_TYPING because its not useful for most bots
- DIRECT_MESSAGE_TYPING because its not useful for most bots
createLight(token)
orcreateDefault(token)
. You can further configure intents by usingenableIntents(intents)
anddisableIntents(intents)
.
-
-
Method Detail
-
values
public static GatewayIntent[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (GatewayIntent c : GatewayIntent.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static GatewayIntent valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
getRawValue
public int getRawValue()
The raw bitmask value for this intent- Returns:
- The raw bitmask value
-
getOffset
public int getOffset()
The offset of the intent flag within a bitmask
This meansgetRawValue() == 1 << getOffset()
- Returns:
- The offset
-
getIntents
@Nonnull public static java.util.EnumSet<GatewayIntent> getIntents(int raw)
Converts a bitmask into anEnumSet
of enum values.- Parameters:
raw
- The raw bitmask- Returns:
EnumSet
of intents
-
getRaw
public static int getRaw(@Nonnull java.util.Collection<GatewayIntent> set)
Converts the given intents to a bitmask- Parameters:
set
- TheCollection
of intents- Returns:
- The bitmask for this set of intents
- Throws:
java.lang.IllegalArgumentException
- If null is provided
-
getRaw
public static int getRaw(@Nonnull GatewayIntent intent, @Nonnull GatewayIntent... set)
Converts the given intents to a bitmask- Parameters:
intent
- The first intentset
- The remaining intents- Returns:
- The bitmask for this set of intents
- Throws:
java.lang.IllegalArgumentException
- If null is provided
-
fromCacheFlags
@Nonnull public static java.util.EnumSet<GatewayIntent> fromCacheFlags(@Nonnull CacheFlag flag, @Nonnull CacheFlag... other)
Parse the required GatewayIntents from the providedCacheFlags
.
This creates anEnumSet
based onCacheFlag.getRequiredIntent()
.- Parameters:
flag
- The first cache flagother
- Any additional cache flags- Returns:
EnumSet
for the required intents- Throws:
java.lang.IllegalArgumentException
- If provided with null
-
fromCacheFlags
@Nonnull public static java.util.EnumSet<GatewayIntent> fromCacheFlags(@Nonnull java.util.Collection<CacheFlag> flags)
Parse the required GatewayIntents from the providedCacheFlags
.
This creates anEnumSet
based onCacheFlag.getRequiredIntent()
.- Parameters:
flags
- The cache flags- Returns:
EnumSet
for the required intents- Throws:
java.lang.IllegalArgumentException
- If provided with null
-
fromEvents
@Nonnull @SafeVarargs public static java.util.EnumSet<GatewayIntent> fromEvents(@Nonnull java.lang.Class<? extends GenericEvent>... events)
Parse the required GatewayIntents from the providedEvent Types
.- Parameters:
events
- The event types- Returns:
EnumSet
for the required intents- Throws:
java.lang.IllegalArgumentException
- If provided with null
-
fromEvents
@Nonnull public static java.util.EnumSet<GatewayIntent> fromEvents(@Nonnull java.util.Collection<java.lang.Class<? extends GenericEvent>> events)
Parse the required GatewayIntents from the providedEvent Types
.- Parameters:
events
- The event types- Returns:
EnumSet
for the required intents- Throws:
java.lang.IllegalArgumentException
- If provided with null
-
from
@Nonnull public static java.util.EnumSet<GatewayIntent> from(@Nonnull java.util.Collection<java.lang.Class<? extends GenericEvent>> events, @Nonnull java.util.Collection<CacheFlag> flags)
Parse the required GatewayIntents from the providedEvent Types
andCacheFlags
.- Parameters:
events
- The event typesflags
- The cache flags- Returns:
EnumSet
for the required intents- Throws:
java.lang.IllegalArgumentException
- If provided with null
-
-