Interface JDA
-
public interface JDA
The core of JDA. Acts as a registry system of JDA. All parts of the the API can be accessed starting from this class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
JDA.ShardInfo
Represents the information used to create this shard.static class
JDA.Status
Represents the connection status of JDA and its Main WebSocket.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addEventListener(java.lang.Object... listeners)
Adds all provided listeners to the event-listeners that will be used to handle events.JDABot
asBot()
Used to access Bot specific functions like OAuth information.JDAClient
asClient()
Used to access Client specific functions like Groups, Calls, and Friends.default JDA
awaitReady()
This method will block until JDA has reached the statusJDA.Status.CONNECTED
.JDA
awaitStatus(JDA.Status status)
This method will block until JDA has reached the specified connection status.GuildAction
createGuild(java.lang.String name)
Constructs a newGuild
with the specified name
Use the returnedGuildAction
to provide further details and settings for the resulting Guild!AccountType
getAccountType()
TheAccountType
of the currently logged in account.CacheView<AudioManager>
getAudioManagerCache()
CacheView
of all cachedAudioManagers
created for this JDA instance.default java.util.List<AudioManager>
getAudioManagers()
Immutable list of all createdAudioManagers
for this JDA instance!default java.util.List<Category>
getCategories()
Gets allCategories
visible to the currently logged in account.default java.util.List<Category>
getCategoriesByName(java.lang.String name, boolean ignoreCase)
Gets a list of allCategories
that have the same name as the one provided.default Category
getCategoryById(long id)
Gets theCategory
that matches the provided id.default Category
getCategoryById(java.lang.String id)
Gets theCategory
that matches the provided id.SnowflakeCacheView<Category>
getCategoryCache()
SnowflakeCacheView
of all cachedCategories
visible to this JDA session.java.util.List<java.lang.String>
getCloudflareRays()
Contains allcf-ray
headers that JDA received in this session.default Emote
getEmoteById(long id)
Retrieves an emote matching the specifiedid
if one is available in our cache.default Emote
getEmoteById(java.lang.String id)
Retrieves an emote matching the specifiedid
if one is available in our cache.SnowflakeCacheView<Emote>
getEmoteCache()
UnifiedSnowflakeCacheView
of all cachedEmotes
visible to this JDA session.default java.util.List<Emote>
getEmotes()
A collection of all to us known emotes (managed/restricted included).default java.util.List<Emote>
getEmotesByName(java.lang.String name, boolean ignoreCase)
An unmodifiable list of allEmotes
that have the same name as the one provided.IEventManager
getEventManager()
The EventManager used by this JDA instance.default Guild
getGuildById(long id)
This returns theGuild
which has the same id as the one provided.default Guild
getGuildById(java.lang.String id)
This returns theGuild
which has the same id as the one provided.SnowflakeCacheView<Guild>
getGuildCache()
SnowflakeCacheView
of all cachedGuilds
visible to this JDA session.default java.util.List<Guild>
getGuilds()
An unmodifiable List of allGuilds
that the logged account is connected to.default java.util.List<Guild>
getGuildsByName(java.lang.String name, boolean ignoreCase)
An unmodifiable list of allGuilds
that have the same name as the one provided.int
getMaxReconnectDelay()
This value is the maximum amount of time, in seconds, that JDA will wait between reconnect attempts.java.util.List<Guild>
getMutualGuilds(java.util.Collection<User> users)
Gets allGuilds
that contain all given users as their members.java.util.List<Guild>
getMutualGuilds(User... users)
Gets allGuilds
that contain all given users as their members.long
getPing()
The time in milliseconds that discord took to respond to our last heartbeat
This roughly represents the WebSocket ping of this sessionPresence
getPresence()
ThePresence
controller for the current session.default PrivateChannel
getPrivateChannelById(long id)
This returns thePrivateChannel
which has the same id as the one provided.default PrivateChannel
getPrivateChannelById(java.lang.String id)
This returns thePrivateChannel
which has the same id as the one provided.SnowflakeCacheView<PrivateChannel>
getPrivateChannelCache()
SnowflakeCacheView
of all cachedPrivateChannels
visible to this JDA session.default java.util.List<PrivateChannel>
getPrivateChannels()
An unmodifiable list of all knownPrivateChannels
.java.util.List<java.lang.Object>
getRegisteredListeners()
Returns an unmodifiable List of Objects that have been registered as EventListeners.long
getResponseTotal()
This value is the total amount of JSON responses that discord has sent.default Role
getRoleById(long id)
Retrieves theRole
associated to the provided id.default Role
getRoleById(java.lang.String id)
Retrieves theRole
associated to the provided id.SnowflakeCacheView<Role>
getRoleCache()
UnifiedSnowflakeCacheView
of all cachedRoles
visible to this JDA session.default java.util.List<Role>
getRoles()
AllRoles
this JDA instance can see.default java.util.List<Role>
getRolesByName(java.lang.String name, boolean ignoreCase)
Retrieves allRoles
visible to this JDA instance.SelfUser
getSelfUser()
Returns the currently logged in account represented bySelfUser
.JDA.ShardInfo
getShardInfo()
The shard information used when creating this instance of JDA.JDA.Status
getStatus()
Gets the currentStatus
of the JDA instance.default TextChannel
getTextChannelById(long id)
This returns theTextChannel
which has the same id as the one provided.default TextChannel
getTextChannelById(java.lang.String id)
This returns theTextChannel
which has the same id as the one provided.SnowflakeCacheView<TextChannel>
getTextChannelCache()
SnowflakeCacheView
of all cachedTextChannels
visible to this JDA session.default java.util.List<TextChannel>
getTextChannels()
An unmodifiable List of allTextChannels
of all connectedGuilds
.default java.util.List<TextChannel>
getTextChannelsByName(java.lang.String name, boolean ignoreCase)
An unmodifiable list of allTextChannels
that have the same name as the one provided.java.lang.String
getToken()
The login token that is currently being used for Discord authentication.default User
getUserById(long id)
This returns theUser
which has the same id as the one provided.default User
getUserById(java.lang.String id)
This returns theUser
which has the same id as the one provided.SnowflakeCacheView<User>
getUserCache()
SnowflakeCacheView
of all cachedUsers
visible to this JDA session.default java.util.List<User>
getUsers()
default java.util.List<User>
getUsersByName(java.lang.String name, boolean ignoreCase)
This unmodifiable returns allUsers
that have the same username as the one provided.default VoiceChannel
getVoiceChannelById(long id)
This returns theVoiceChannel
which has the same id as the one provided.default VoiceChannel
getVoiceChannelById(java.lang.String id)
This returns theVoiceChannel
which has the same id as the one provided.default java.util.List<VoiceChannel>
getVoiceChannelByName(java.lang.String name, boolean ignoreCase)
An unmodifiable list of allVoiceChannels
that have the same name as the one provided.SnowflakeCacheView<VoiceChannel>
getVoiceChannelCache()
SnowflakeCacheView
of all cachedVoiceChannels
visible to this JDA session.default java.util.List<VoiceChannel>
getVoiceChannels()
An unmodifiable list of allVoiceChannels
of all connectedGuilds
.default RestAction<Webhook>
getWebhookById(long webhookId)
Retrieves aWebhook
by its id.RestAction<Webhook>
getWebhookById(java.lang.String webhookId)
Retrieves aWebhook
by its id.java.util.List<java.lang.String>
getWebSocketTrace()
Receives all valid_trace
lines that have been sent to us in this session.boolean
isAudioEnabled()
Used to determine whether the instance of JDA supports audio and has it enabled.boolean
isAutoReconnect()
USed to determine whether or not autoReconnect is enabled for JDA.boolean
isBulkDeleteSplittingEnabled()
Used to determine if JDA will process MESSAGE_DELETE_BULK messages received from Discord as a singleMessageBulkDeleteEvent
or split the deleted messages up and fire multipleMessageDeleteEvents
, one for each deleted message.void
removeEventListener(java.lang.Object... listeners)
Removes all provided listeners from the event-listeners and no longer uses them to handle events.RestAction<User>
retrieveUserById(long id)
Attempts to retrieve aUser
object based on the provided id.RestAction<User>
retrieveUserById(java.lang.String id)
Attempts to retrieve aUser
object based on the provided id.void
setAutoReconnect(boolean reconnect)
Sets whether or not JDA should try to automatically reconnect if a connection-error is encountered.void
setEventManager(IEventManager manager)
Changes the internal EventManager.void
setRequestTimeoutRetry(boolean retryOnTimeout)
Whether the Requester should retry when aSocketTimeoutException
occurs.void
shutdown()
Shuts down this JDA instance, closing all its connections.void
shutdownNow()
Shuts down this JDA instance instantly, closing all its connections.
-
-
-
Method Detail
-
getStatus
JDA.Status getStatus()
Gets the currentStatus
of the JDA instance.- Returns:
- Current JDA status.
-
getPing
long getPing()
The time in milliseconds that discord took to respond to our last heartbeat
This roughly represents the WebSocket ping of this sessionRestAction
request times do not correlate to this value!- Returns:
- time in milliseconds between heartbeat and the heartbeat ack response
-
awaitStatus
JDA awaitStatus(JDA.Status status) throws java.lang.InterruptedException
This method will block until JDA has reached the specified connection status.Login Cycle
- Parameters:
status
- The init status to wait for, once JDA has reached the specified stage of the startup cycle this method will return.- Returns:
- The current JDA instance, for chaining convenience
- Throws:
java.lang.InterruptedException
- If this thread is interrupted while waitingjava.lang.IllegalArgumentException
- If the provided status is null or not an init status (JDA.Status.isInit()
)java.lang.IllegalStateException
- If JDA is shutdown during this wait period
-
awaitReady
default JDA awaitReady() throws java.lang.InterruptedException
This method will block until JDA has reached the statusJDA.Status.CONNECTED
.
This status means that JDA finished setting up its internal cache and is ready to be used.- Returns:
- The current JDA instance, for chaining convenience
- Throws:
java.lang.InterruptedException
- If this thread is interrupted while waitingjava.lang.IllegalStateException
- If JDA is shutdown during this wait period
-
getCloudflareRays
java.util.List<java.lang.String> getCloudflareRays()
Contains allcf-ray
headers that JDA received in this session.
These receive a new value whenever the WebSockedClient reconnects to the gateway.This is useful to monitor cloudflare activity from the Discord Developer perspective.
Use this list to report connection issues.- Returns:
- Immutable list of all cf-ray values for this session
-
getWebSocketTrace
java.util.List<java.lang.String> getWebSocketTrace()
Receives all valid_trace
lines that have been sent to us in this session.
These values reset on every reconnect! (not resume)- Returns:
- List of all websocket traces
-
setEventManager
void setEventManager(IEventManager manager)
Changes the internal EventManager.The default EventManager is
InterfacedEventListener
.
There is also anAnnotatedEventManager
available.- Parameters:
manager
- The new EventManager to use
-
addEventListener
void addEventListener(java.lang.Object... listeners)
Adds all provided listeners to the event-listeners that will be used to handle events. This uses theInterfacedEventListener
by default. To switch to theAnnotatedEventManager
, usesetEventManager(IEventManager)
. Note: when using theInterfacedEventListener
(default), given listener must be instance ofEventListener
!- Parameters:
listeners
- The listener(s) which will react to events.- Throws:
java.lang.IllegalArgumentException
- If either listeners or one of it's objects isnull
.
-
removeEventListener
void removeEventListener(java.lang.Object... listeners)
Removes all provided listeners from the event-listeners and no longer uses them to handle events.- Parameters:
listeners
- The listener(s) to be removed.- Throws:
java.lang.IllegalArgumentException
- If either listeners or one of it's objects isnull
.
-
getRegisteredListeners
java.util.List<java.lang.Object> getRegisteredListeners()
Returns an unmodifiable List of Objects that have been registered as EventListeners.- Returns:
- List of currently registered Objects acting as EventListeners.
-
createGuild
GuildAction createGuild(java.lang.String name)
Constructs a newGuild
with the specified name
Use the returnedGuildAction
to provide further details and settings for the resulting Guild!This RestAction does not provide the resulting Guild! It will be in a following
GuildJoinEvent
.- Parameters:
name
- The name of the resulting guild- Returns:
GuildAction
Allows for setting various details for the resulting Guild- Throws:
java.lang.IllegalStateException
- If the currently logged in account is fromAccountType.CLIENT
and the account is in 100 or more guildsAccountType.BOT
and the account is in 10 or more guilds
java.lang.IllegalArgumentException
- If the provided name is empty,null
or not between 2-100 characters
-
getAudioManagerCache
CacheView<AudioManager> getAudioManagerCache()
CacheView
of all cachedAudioManagers
created for this JDA instance.
AudioManagers are created when first retrieved viaGuild.getAudioManager()
. Using this will perform better than callingGuild.getAudioManager()
iteratively as that would cause many useless audio managers to be created!AudioManagers are cross-session persistent!
- Returns:
CacheView
-
getAudioManagers
default java.util.List<AudioManager> getAudioManagers()
Immutable list of all createdAudioManagers
for this JDA instance!- Returns:
- Immutable list of all created AudioManager instances
-
getUserCache
SnowflakeCacheView<User> getUserCache()
SnowflakeCacheView
of all cachedUsers
visible to this JDA session.- Returns:
SnowflakeCacheView
-
getUsers
default java.util.List<User> getUsers()
An unmodifiable list of allUsers
that share aGuild
with the currently logged in account.
This list will never contain duplicates and represents allUsers
that JDA can currently see.If the developer is sharding, then only users from guilds connected to the specifically logged in shard will be returned in the List.
- Returns:
- List of all
Users
that are visible to JDA.
-
getUserById
default User getUserById(java.lang.String id)
This returns theUser
which has the same id as the one provided.
If there is no visible user with an id that matches the provided one, this returnsnull
.
-
getUserById
default User getUserById(long id)
This returns theUser
which has the same id as the one provided.
If there is no visible user with an id that matches the provided one, this returnsnull
.
-
getUsersByName
default java.util.List<User> getUsersByName(java.lang.String name, boolean ignoreCase)
This unmodifiable returns allUsers
that have the same username as the one provided.
If there are noUsers
with the provided name, then this returns an empty list.Note: This does **not** consider nicknames, it only considers
User.getName()
- Parameters:
name
- The name of the requestedUsers
.ignoreCase
- Whether to ignore case or not when comparing the provided name to eachUser.getName()
.- Returns:
- Possibly-empty list of
Users
that all have the same name as the provided name.
-
getMutualGuilds
java.util.List<Guild> getMutualGuilds(User... users)
Gets allGuilds
that contain all given users as their members.
-
getMutualGuilds
java.util.List<Guild> getMutualGuilds(java.util.Collection<User> users)
Gets allGuilds
that contain all given users as their members.
-
retrieveUserById
@CheckReturnValue RestAction<User> retrieveUserById(java.lang.String id)
Attempts to retrieve aUser
object based on the provided id.
This first callsgetUserById(long)
, and if the return isnull
then a request is made to the Discord servers.The returned
RestAction
can encounter the following Discord errors:ErrorResponse.UNKNOWN_USER
Occurs when the provided id does not refer to aUser
known by Discord. Typically occurs when developers provide an incomplete id (cut short).
- Parameters:
id
- The id of the requestedUser
.- Returns:
RestAction
- Type:User
On request, gets the User with id matching provided id from Discord.- Throws:
AccountTypeException
- This endpoint isAccountType.BOT
only.java.lang.NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
java.lang.IllegalArgumentException
-- If the provided id String is null.
- If the provided id String is empty.
-
retrieveUserById
@CheckReturnValue RestAction<User> retrieveUserById(long id)
Attempts to retrieve aUser
object based on the provided id.
This first callsgetUserById(long)
, and if the return isnull
then a request is made to the Discord servers.The returned
RestAction
can encounter the following Discord errors:ErrorResponse.UNKNOWN_USER
Occurs when the provided id does not refer to aUser
known by Discord. Typically occurs when developers provide an incomplete id (cut short).
- Parameters:
id
- The id of the requestedUser
.- Returns:
RestAction
- Type:User
On request, gets the User with id matching provided id from Discord.- Throws:
AccountTypeException
- This endpoint isAccountType.BOT
only.
-
getGuildCache
SnowflakeCacheView<Guild> getGuildCache()
SnowflakeCacheView
of all cachedGuilds
visible to this JDA session.- Returns:
SnowflakeCacheView
-
getGuilds
default java.util.List<Guild> getGuilds()
An unmodifiable List of allGuilds
that the logged account is connected to.
If this account is not connected to anyGuilds
, this will return an empty list.If the developer is sharding (
JDABuilder.useSharding(int, int)
, then this list will only contain theGuilds
that the shard is actually connected to. Discord determines which guilds a shard is connect to using the following format:
Guild connected if shardId == (guildId >> 22) % totalShards;
Source for formula: Discord Documentation- Returns:
- Possibly-empty list of all the
Guilds
that this account is connected to.
-
getGuildById
default Guild getGuildById(java.lang.String id)
This returns theGuild
which has the same id as the one provided.
If there is no connected guild with an id that matches the provided one, then this returnsnull
.
-
getGuildById
default Guild getGuildById(long id)
This returns theGuild
which has the same id as the one provided.
If there is no connected guild with an id that matches the provided one, then this returnsnull
.
-
getGuildsByName
default java.util.List<Guild> getGuildsByName(java.lang.String name, boolean ignoreCase)
An unmodifiable list of allGuilds
that have the same name as the one provided.
If there are noGuilds
with the provided name, then this returns an empty list.- Parameters:
name
- The name of the requestedGuilds
.ignoreCase
- Whether to ignore case or not when comparing the provided name to eachGuild.getName()
.- Returns:
- Possibly-empty list of all the
Guilds
that all have the same name as the provided name.
-
getRoleCache
SnowflakeCacheView<Role> getRoleCache()
UnifiedSnowflakeCacheView
of all cachedRoles
visible to this JDA session.- Returns:
- Unified
SnowflakeCacheView
- See Also:
CacheView.allSnowflakes(...)
-
getRoles
default java.util.List<Role> getRoles()
AllRoles
this JDA instance can see.
This will iterate over eachGuild
retrieved fromgetGuilds()
and collect itsGuild.getRoles()
.- Returns:
- Immutable List of all visible Roles
-
getRoleById
default Role getRoleById(java.lang.String id)
Retrieves theRole
associated to the provided id.
This iterates over allGuilds
and check whether a Role from that Guild is assigned to the specified ID and will return the first that can be found.- Parameters:
id
- The id of the searched Role- Returns:
- Possibly-null
Role
for the specified ID - Throws:
java.lang.NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
-
getRoleById
default Role getRoleById(long id)
Retrieves theRole
associated to the provided id.
This iterates over allGuilds
and check whether a Role from that Guild is assigned to the specified ID and will return the first that can be found.- Parameters:
id
- The id of the searched Role- Returns:
- Possibly-null
Role
for the specified ID
-
getRolesByName
default java.util.List<Role> getRolesByName(java.lang.String name, boolean ignoreCase)
Retrieves allRoles
visible to this JDA instance.
This simply filters the Roles returned bygetRoles()
with the provided name, either usingString.equals(Object)
orString.equalsIgnoreCase(String)
onRole.getName()
.- Parameters:
name
- The name for the RolesignoreCase
- Whether to useString.equalsIgnoreCase(String)
- Returns:
- Immutable List of all Roles matching the parameters provided.
-
getCategoryCache
SnowflakeCacheView<Category> getCategoryCache()
SnowflakeCacheView
of all cachedCategories
visible to this JDA session.- Returns:
SnowflakeCacheView
-
getCategoryById
default Category getCategoryById(java.lang.String id)
- Parameters:
id
- The snowflake ID of the wanted Category- Returns:
- Possibly-null
Category
for the provided ID. - Throws:
java.lang.IllegalArgumentException
- If the provided ID is not a validlong
-
getCategoryById
default Category getCategoryById(long id)
- Parameters:
id
- The snowflake ID of the wanted Category- Returns:
- Possibly-null
Category
for the provided ID.
-
getCategories
default java.util.List<Category> getCategories()
Gets allCategories
visible to the currently logged in account.- Returns:
- An immutable list of all visible
Categories
.
-
getCategoriesByName
default java.util.List<Category> getCategoriesByName(java.lang.String name, boolean ignoreCase)
Gets a list of allCategories
that have the same name as the one provided.
If there are no matching categories this will return an empty list.- Parameters:
name
- The name to checkignoreCase
- Whether to ignore case on name checking- Returns:
- Immutable list of all categories matching the provided name
- Throws:
java.lang.IllegalArgumentException
- If the provided name isnull
-
getTextChannelCache
SnowflakeCacheView<TextChannel> getTextChannelCache()
SnowflakeCacheView
of all cachedTextChannels
visible to this JDA session.- Returns:
SnowflakeCacheView
-
getTextChannels
default java.util.List<TextChannel> getTextChannels()
An unmodifiable List of allTextChannels
of all connectedGuilds
.Note: just because a
TextChannel
is present in this list does not mean that you will be able to send messages to it. Furthermore, if you log into this account on the discord client, it is possible that you will see fewer channels than this returns. This is because the discord client hides anyTextChannel
that you don't have thePermission.MESSAGE_READ
permission in.- Returns:
- Possibly-empty list of all known
TextChannels
.
-
getTextChannelById
default TextChannel getTextChannelById(java.lang.String id)
This returns theTextChannel
which has the same id as the one provided.
If there is no knownTextChannel
with an id that matches the provided one, then this returnsnull
.Note: just because a
TextChannel
is present does not mean that you will be able to send messages to it. Furthermore, if you log into this account on the discord client, it is you will not see the channel that this returns. This is because the discord client hides anyTextChannel
that you don't have thePermission.MESSAGE_READ
permission in.- Parameters:
id
- The id of theTextChannel
.- Returns:
- Possibly-null
TextChannel
with matching id. - Throws:
java.lang.NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
-
getTextChannelById
default TextChannel getTextChannelById(long id)
This returns theTextChannel
which has the same id as the one provided.
If there is no knownTextChannel
with an id that matches the provided one, then this returnsnull
.Note: just because a
TextChannel
is present does not mean that you will be able to send messages to it. Furthermore, if you log into this account on the discord client, it is you will not see the channel that this returns. This is because the discord client hides anyTextChannel
that you don't have thePermission.MESSAGE_READ
permission in.- Parameters:
id
- The id of theTextChannel
.- Returns:
- Possibly-null
TextChannel
with matching id.
-
getTextChannelsByName
default java.util.List<TextChannel> getTextChannelsByName(java.lang.String name, boolean ignoreCase)
An unmodifiable list of allTextChannels
that have the same name as the one provided.
If there are noTextChannels
with the provided name, then this returns an empty list.Note: just because a
TextChannel
is present in this list does not mean that you will be able to send messages to it. Furthermore, if you log into this account on the discord client, it is possible that you will see fewer channels than this returns. This is because the discord client hides anyTextChannel
that you don't have thePermission.MESSAGE_READ
permission in.- Parameters:
name
- The name of the requestedTextChannels
.ignoreCase
- Whether to ignore case or not when comparing the provided name to eachChannel.getName()
.- Returns:
- Possibly-empty list of all the
TextChannels
that all have the same name as the provided name.
-
getVoiceChannelCache
SnowflakeCacheView<VoiceChannel> getVoiceChannelCache()
SnowflakeCacheView
of all cachedVoiceChannels
visible to this JDA session.- Returns:
SnowflakeCacheView
-
getVoiceChannels
default java.util.List<VoiceChannel> getVoiceChannels()
An unmodifiable list of allVoiceChannels
of all connectedGuilds
.- Returns:
- Possible-empty list of all known
VoiceChannels
.
-
getVoiceChannelById
default VoiceChannel getVoiceChannelById(java.lang.String id)
This returns theVoiceChannel
which has the same id as the one provided.
If there is no knownVoiceChannel
with an id that matches the provided one, then this returnsnull
.- Parameters:
id
- The id of theVoiceChannel
.- Returns:
- Possibly-null
VoiceChannel
with matching id. - Throws:
java.lang.NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
-
getVoiceChannelById
default VoiceChannel getVoiceChannelById(long id)
This returns theVoiceChannel
which has the same id as the one provided.
If there is no knownVoiceChannel
with an id that matches the provided one, then this returnsnull
.- Parameters:
id
- The id of theVoiceChannel
.- Returns:
- Possibly-null
VoiceChannel
with matching id.
-
getVoiceChannelByName
default java.util.List<VoiceChannel> getVoiceChannelByName(java.lang.String name, boolean ignoreCase)
An unmodifiable list of allVoiceChannels
that have the same name as the one provided.
If there are noVoiceChannels
with the provided name, then this returns an empty list.- Parameters:
name
- The name of the requestedVoiceChannels
.ignoreCase
- Whether to ignore case or not when comparing the provided name to eachChannel.getName()
.- Returns:
- Possibly-empty list of all the
VoiceChannels
that all have the same name as the provided name.
-
getPrivateChannelCache
SnowflakeCacheView<PrivateChannel> getPrivateChannelCache()
SnowflakeCacheView
of all cachedPrivateChannels
visible to this JDA session.- Returns:
SnowflakeCacheView
-
getPrivateChannels
default java.util.List<PrivateChannel> getPrivateChannels()
An unmodifiable list of all knownPrivateChannels
.- Returns:
- Possibly-empty list of all
PrivateChannels
.
-
getPrivateChannelById
default PrivateChannel getPrivateChannelById(java.lang.String id)
This returns thePrivateChannel
which has the same id as the one provided.
If there is no knownPrivateChannel
with an id that matches the provided one, then this returnsnull
.- Parameters:
id
- The id of thePrivateChannel
.- Returns:
- Possibly-null
PrivateChannel
with matching id. - Throws:
java.lang.NumberFormatException
- If the providedid
cannot be parsed byLong.parseLong(String)
-
getPrivateChannelById
default PrivateChannel getPrivateChannelById(long id)
This returns thePrivateChannel
which has the same id as the one provided.
If there is no knownPrivateChannel
with an id that matches the provided one, then this returnsnull
.- Parameters:
id
- The id of thePrivateChannel
.- Returns:
- Possibly-null
PrivateChannel
with matching id.
-
getEmoteCache
SnowflakeCacheView<Emote> getEmoteCache()
UnifiedSnowflakeCacheView
of all cachedEmotes
visible to this JDA session.- Returns:
- Unified
SnowflakeCacheView
- See Also:
CacheView.allSnowflakes(...)
-
getEmotes
default java.util.List<Emote> getEmotes()
A collection of all to us known emotes (managed/restricted included).
This will be empty ifCacheFlag.EMOTE
is disabled.Hint: To check whether you can use an
Emote
in a specific context you can useEmote.canInteract(net.dv8tion.jda.core.entities.Member)
orEmote.canInteract(net.dv8tion.jda.core.entities.User, net.dv8tion.jda.core.entities.MessageChannel)
Unicode emojis are not included as
Emote
!- Returns:
- An immutable list of Emotes (which may or may not be available to usage).
-
getEmoteById
default Emote getEmoteById(java.lang.String id)
Retrieves an emote matching the specifiedid
if one is available in our cache.
This will be null ifCacheFlag.EMOTE
is disabled.Unicode emojis are not included as
Emote
!
-
getEmoteById
default Emote getEmoteById(long id)
Retrieves an emote matching the specifiedid
if one is available in our cache.
This will be null ifCacheFlag.EMOTE
is disabled.Unicode emojis are not included as
Emote
!
-
getEmotesByName
default java.util.List<Emote> getEmotesByName(java.lang.String name, boolean ignoreCase)
An unmodifiable list of allEmotes
that have the same name as the one provided.
If there are noEmotes
with the provided name, then this returns an empty list.
This will be empty ifCacheFlag.EMOTE
is disabled.Unicode emojis are not included as
Emote
!- Parameters:
name
- The name of the requestedEmotes
.ignoreCase
- Whether to ignore case or not when comparing the provided name to eachEmote.getName()
.- Returns:
- Possibly-empty list of all the
Emotes
that all have the same name as the provided name.
-
getEventManager
IEventManager getEventManager()
The EventManager used by this JDA instance.- Returns:
- The
IEventManager
-
getSelfUser
SelfUser getSelfUser()
Returns the currently logged in account represented bySelfUser
.
Account settings cannot be modified using this object. If you wish to modify account settings please use the AccountManager which is accessible bySelfUser.getManager()
.- Returns:
- The currently logged in account.
-
getShardInfo
JDA.ShardInfo getShardInfo()
The shard information used when creating this instance of JDA.
Represents the information provided toJDABuilder.useSharding(int, int)
.- Returns:
- The shard information for this shard or
null
if this JDA instance isn't sharding.
-
getToken
java.lang.String getToken()
The login token that is currently being used for Discord authentication.- Returns:
- Never-null, 18 character length string containing the auth token.
-
getResponseTotal
long getResponseTotal()
This value is the total amount of JSON responses that discord has sent.
This value resets every time the websocket has to perform a full reconnect (not resume).- Returns:
- Never-negative long containing total response amount.
-
getMaxReconnectDelay
int getMaxReconnectDelay()
This value is the maximum amount of time, in seconds, that JDA will wait between reconnect attempts.
Can be set usingJDABuilder.setMaxReconnectDelay(int)
.- Returns:
- The maximum amount of time JDA will wait between reconnect attempts in seconds.
-
setAutoReconnect
void setAutoReconnect(boolean reconnect)
Sets whether or not JDA should try to automatically reconnect if a connection-error is encountered.
This will use an incremental reconnect (timeouts are increased each time an attempt fails).Default is true.
- Parameters:
reconnect
- If true - enables autoReconnect
-
setRequestTimeoutRetry
void setRequestTimeoutRetry(boolean retryOnTimeout)
Whether the Requester should retry when aSocketTimeoutException
occurs.- Parameters:
retryOnTimeout
- True, if the Request should retry once on a socket timeout
-
isAutoReconnect
boolean isAutoReconnect()
USed to determine whether or not autoReconnect is enabled for JDA.- Returns:
- True if JDA will attempt to automatically reconnect when a connection-error is encountered.
-
isAudioEnabled
boolean isAudioEnabled()
Used to determine whether the instance of JDA supports audio and has it enabled.- Returns:
- True if JDA can currently utilize the audio system.
-
isBulkDeleteSplittingEnabled
boolean isBulkDeleteSplittingEnabled()
Used to determine if JDA will process MESSAGE_DELETE_BULK messages received from Discord as a singleMessageBulkDeleteEvent
or split the deleted messages up and fire multipleMessageDeleteEvents
, one for each deleted message.By default, JDA will separate the bulk delete event into individual delete events, but this isn't as efficient as handling a single event would be. It is recommended that BulkDelete Splitting be disabled and that the developer should instead handle the
MessageBulkDeleteEvent
- Returns:
- Whether or not JDA currently handles the BULK_MESSAGE_DELETE event by splitting it into individual MessageDeleteEvents or not.
-
shutdown
void shutdown()
Shuts down this JDA instance, closing all its connections. After this command is issued the JDA Instance can not be used anymore. Already enqueuedRestActions
are still going to be executed.If you want this instance to shutdown without executing, use
shutdownNow()
- See Also:
shutdownNow()
-
shutdownNow
void shutdownNow()
Shuts down this JDA instance instantly, closing all its connections. After this command is issued the JDA Instance can not be used anymore. This will also cancel all queuedRestActions
.If you want this instance to shutdown without cancelling enqueued RestActions use
shutdown()
- See Also:
shutdown()
-
getAccountType
AccountType getAccountType()
TheAccountType
of the currently logged in account.
Used when determining functions that are restricted based on the type of account.- Returns:
- The current AccountType.
-
asClient
JDAClient asClient()
Used to access Client specific functions like Groups, Calls, and Friends.- Returns:
- The
JDAClient
registry for this instance of JDA. - Throws:
AccountTypeException
- Thrown if the currently logged in account isAccountType.BOT
-
asBot
JDABot asBot()
Used to access Bot specific functions like OAuth information.- Returns:
- The
JDABot
registry for this instance of JDA. - Throws:
AccountTypeException
- Thrown if the currently logged in account isAccountType.CLIENT
-
getWebhookById
RestAction<Webhook> getWebhookById(java.lang.String webhookId)
Retrieves aWebhook
by its id.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
We do not have the required permissionsUNKNOWN_WEBHOOK
A webhook with this id does not exist
- Parameters:
webhookId
- The webhook id- Returns:
RestAction
- Type:Webhook
The webhook object.- Throws:
java.lang.IllegalArgumentException
- If thewebhookId
is null or empty- See Also:
Guild.getWebhooks()
,TextChannel.getWebhooks()
-
getWebhookById
default RestAction<Webhook> getWebhookById(long webhookId)
Retrieves aWebhook
by its id.Possible
ErrorResponses
caused by the returnedRestAction
include the following:MISSING_PERMISSIONS
We do not have the required permissionsUNKNOWN_WEBHOOK
A webhook with this id does not exist
- Parameters:
webhookId
- The webhook id- Returns:
RestAction
- Type:Webhook
The webhook object.- See Also:
Guild.getWebhooks()
,TextChannel.getWebhooks()
-
-