public interface JDA
Modifier and Type | Interface and 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.
|
Modifier and Type | Method and 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.
|
AccountType |
getAccountType()
The
AccountType of the currently logged in account. |
Emote |
getEmoteById(java.lang.String id)
Retrieves an emote matching the specified
id if one is available in our cache. |
java.util.List<Emote> |
getEmotes()
A collection of all to us known emotes (managed/restricted included).
|
java.util.List<Emote> |
getEmotesByName(java.lang.String name,
boolean ignoreCase)
An unmodifiable list of all
Emotes that have the same name as the one provided. |
org.apache.http.HttpHost |
getGlobalProxy()
The proxy settings used by all JDA instances.
|
Guild |
getGuildById(java.lang.String id)
This returns the
Guild which has the same id as the one provided. |
java.util.List<Guild> |
getGuilds()
An unmodifiable List of all
Guilds that the logged account is connected to. |
java.util.List<Guild> |
getGuildsByName(java.lang.String name,
boolean ignoreCase)
An unmodifiable list of all
Guilds that have the same name as the one provided. |
java.util.List<Guild> |
getMutualGuilds(java.util.Collection<User> users)
Gets all
Guilds that contain all given users as their members. |
java.util.List<Guild> |
getMutualGuilds(User... users)
Gets all
Guilds 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 session |
Presence |
getPresence()
The
Presence controller for the current session. |
PrivateChannel |
getPrivateChannelById(java.lang.String id)
This returns the
PrivateChannel which has the same id as the one provided. |
java.util.List<PrivateChannel> |
getPrivateChannels()
An unmodifiable list of all known
PrivateChannels . |
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.
|
SelfUser |
getSelfUser()
Returns the currently logged in account represented by
SelfUser . |
JDA.ShardInfo |
getShardInfo()
The shard information used when creating this instance of JDA.
|
JDA.Status |
getStatus()
Gets the current
Status of the JDA instance. |
TextChannel |
getTextChannelById(java.lang.String id)
This returns the
TextChannel which has the same id as the one provided. |
java.util.List<TextChannel> |
getTextChannels()
An unmodifiable List of all
TextChannels of all connected
Guilds . |
java.util.List<TextChannel> |
getTextChannelsByName(java.lang.String name,
boolean ignoreCase)
An unmodifiable list of all
TextChannels that have the same name as the one provided. |
java.lang.String |
getToken()
The login token that is currently being used for Discord authentication.
|
User |
getUserById(java.lang.String id)
This returns the
User which has the same id as the one provided. |
java.util.List<User> |
getUsers()
|
java.util.List<User> |
getUsersByName(java.lang.String name,
boolean ignoreCase)
This unmodifiable returns all
Users that have the same username as the one provided. |
VoiceChannel |
getVoiceChannelById(java.lang.String id)
This returns the
VoiceChannel which has the same id as the one provided. |
java.util.List<VoiceChannel> |
getVoiceChannelByName(java.lang.String name,
boolean ignoreCase)
An unmodifiable list of all
VoiceChannels that have the same name as the one provided. |
java.util.List<VoiceChannel> |
getVoiceChannels()
An unmodifiable list of all
VoiceChannels of all connected
Guilds . |
void |
installAuxiliaryCable(int port)
Installs an auxiliary cable into your system.
|
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 single
MessageBulkDeleteEvent or split
the deleted messages up and fire multiple MessageDeleteEvents ,
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(java.lang.String id)
Attempts to retrieve a
User 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 |
shutdown()
Shuts down JDA, closing all its connections.
|
void |
shutdown(boolean free)
Shuts down JDA, closing all its connections.
|
JDA.Status getStatus()
Status
of the JDA instance.long getPing()
RestAction
request times do not
correlate to this value!
void setEventManager(IEventManager manager)
The default EventManager is InterfacedEventListener
.
There is also an AnnotatedEventManager
available.
manager
- The new EventManager to usevoid addEventListener(java.lang.Object... listeners)
InterfacedEventListener
by default.
To switch to the AnnotatedEventManager
, use setEventManager(IEventManager)
.
Note: when using the InterfacedEventListener
(default),
given listener must be instance of EventListener
!listeners
- The listener(s) which will react to events.void removeEventListener(java.lang.Object... listeners)
listeners
- The listener(s) to be removed.java.util.List<java.lang.Object> getRegisteredListeners()
java.util.List<User> getUsers()
Users
that share a
Guild
with the currently logged in account.
Users
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.
Users
that are visible to JDA.User getUserById(java.lang.String id)
User
which has the same id as the one provided.
null
.java.util.List<Guild> getMutualGuilds(User... users)
Guilds
that contain all given users as their members.java.util.List<Guild> getMutualGuilds(java.util.Collection<User> users)
Guilds
that contain all given users as their members.java.util.List<User> getUsersByName(java.lang.String name, boolean ignoreCase)
Users
that have the same username as the one provided.
Users
with the provided name, then this returns an empty list.
Note: This does **not** consider nicknames, it only considers User.getName()
name
- The name of the requested Users
.ignoreCase
- Whether to ignore case or not when comparing the provided name to each User.getName()
.Users
that all have the same name as the provided name.RestAction<User> retrieveUserById(java.lang.String id)
User
object based on the provided id.
getUserById(String)
, and if the return is null
then a request
is made to the Discord servers.
The returned RestAction
can encounter the following Discord errors:
ErrorResponse.UNKNOWN_USER
User
known by Discord. Typically occurs when developers provide an incomplete id (cut short), or something that
is not an id at all! (like a user name or something similar).id
- The id of the requested User
.RestAction
- Type: User
AccountTypeException
- This endpoint is AccountType.BOT
only.java.lang.IllegalArgumentException
- java.util.List<Guild> getGuilds()
Guilds
that the logged account is connected to.
Guilds
, this will return
an empty list.
If the developer is sharding (JDABuilder.useSharding(int, int)
,
then this list will only contain the Guilds
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
Guilds
that this account is connected to.Guild getGuildById(java.lang.String id)
Guild
which has the same id as the one provided.
null
.java.util.List<Guild> getGuildsByName(java.lang.String name, boolean ignoreCase)
Guilds
that have the same name as the one provided.
Guilds
with the provided name, then this returns an empty list.name
- The name of the requested Guilds
.ignoreCase
- Whether to ignore case or not when comparing the provided name to each Guild.getName()
.Guilds
that all have the same name as
the provided name.java.util.List<TextChannel> getTextChannels()
TextChannels
of all connected
Guilds
.
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 any TextChannel
that you don't have the
Permission.MESSAGE_READ
permission in.
TextChannels
.TextChannel getTextChannelById(java.lang.String id)
TextChannel
which has the same id as the one provided.
TextChannel
with an id that matches the provided
one, then this returns null
.
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 any TextChannel
that you don't have the
Permission.MESSAGE_READ
permission in.
id
- The id of the TextChannel
.TextChannel
with matching id.java.util.List<TextChannel> getTextChannelsByName(java.lang.String name, boolean ignoreCase)
TextChannels
that have the same name as the one provided.
TextChannels
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 any TextChannel
that you don't have the
Permission.MESSAGE_READ
permission in.
name
- The name of the requested TextChannels
.ignoreCase
- Whether to ignore case or not when comparing the provided name to each Channel.getName()
.TextChannels
that all have the
same name as the provided name.java.util.List<VoiceChannel> getVoiceChannels()
VoiceChannels
of all connected
Guilds
.VoiceChannels
.VoiceChannel getVoiceChannelById(java.lang.String id)
VoiceChannel
which has the same id as the one provided.
VoiceChannel
with an id that matches the provided
one, then this returns null
.id
- The id of the VoiceChannel
.VoiceChannel
with matching id.java.util.List<VoiceChannel> getVoiceChannelByName(java.lang.String name, boolean ignoreCase)
VoiceChannels
that have the same name as the one provided.
VoiceChannels
with the provided name, then this returns an empty list.name
- The name of the requested VoiceChannels
.ignoreCase
- Whether to ignore case or not when comparing the provided name to each Channel.getName()
.VoiceChannels
that all have the
same name as the provided name.java.util.List<PrivateChannel> getPrivateChannels()
PrivateChannels
.PrivateChannels
.PrivateChannel getPrivateChannelById(java.lang.String id)
PrivateChannel
which has the same id as the one provided.
PrivateChannel
with an id that matches the
provided one, then this returns null
.id
- The id of the PrivateChannel
.PrivateChannel
with matching id.java.util.List<Emote> getEmotes()
Hint: To check whether you can use an Emote
in a specific
context you can use Emote.canInteract(net.dv8tion.jda.core.entities.Member)
or
Emote.canInteract(net.dv8tion.jda.core.entities.User, net.dv8tion.jda.core.entities.MessageChannel)
Emote getEmoteById(java.lang.String id)
id
if one is available in our cache.java.util.List<Emote> getEmotesByName(java.lang.String name, boolean ignoreCase)
Emotes
that have the same name as the one provided.
Emotes
with the provided name, then this returns an empty list.name
- The name of the requested Emotes
.ignoreCase
- Whether to ignore case or not when comparing the provided name to each Emote.getName()
.Emotes
that all have the
same name as the provided name.SelfUser getSelfUser()
SelfUser
.
SelfUser.getManager()
or
SelfUser.getManagerUpdatable()
.JDA.ShardInfo getShardInfo()
JDABuilder.useSharding(int, int)
.null
if this JDA instance isn't sharding.java.lang.String getToken()
long getResponseTotal()
org.apache.http.HttpHost getGlobalProxy()
Proxy.NO_PROXY
is returned.void setAutoReconnect(boolean reconnect)
Default is true.
reconnect
- If true - enables autoReconnectboolean isAutoReconnect()
boolean isAudioEnabled()
boolean isBulkDeleteSplittingEnabled()
MessageBulkDeleteEvent
or split
the deleted messages up and fire multiple MessageDeleteEvents
,
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
void shutdown()
This is the same as calling shutdown(true)
.
void shutdown(boolean free)
Depending on the value of free
, this will also close the background-thread used for requests by Unirest.
If the background-thread is closed, the system can exit properly, but no further JDA requests are possible (includes other JDA instances).
If you want to create any new instances or if you have any other instances running in parallel, then free
should be set to false.
free
- If true, shuts down JDA's rest system permanently for all current and future instances.void installAuxiliaryCable(int port) throws java.lang.UnsupportedOperationException
port
- the port to install to.java.lang.UnsupportedOperationException
- when you don't read the docsAccountType getAccountType()
AccountType
of the currently logged in account.
JDAClient asClient()
JDAClient
registry for this instance of JDA.AccountTypeException
- Thrown if the currently logged in account is AccountType.BOT
JDABot asBot()
JDABot
registry for this instance of JDA.AccountTypeException
- Thrown if the currently logged in account is AccountType.CLIENT