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. |
java.util.List<java.lang.String> |
getCloudflareRays()
Contains all
cf-ray headers that JDA received in this session. |
Emote |
getEmoteById(long id)
Retrieves an emote matching the specified
id if one is available in our cache. |
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. |
Guild |
getGuildById(long id)
This returns the
Guild which has the same id as the one provided. |
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. |
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 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(long id)
This returns the
PrivateChannel which has the same id as the one provided. |
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.
|
Role |
getRoleById(long id)
Retrieves the
Role associated to the provided id. |
Role |
getRoleById(java.lang.String id)
Retrieves the
Role associated to the provided id. |
java.util.List<Role> |
getRoles()
All
Roles this JDA instance can see. |
java.util.List<Role> |
getRolesByName(java.lang.String name,
boolean ignoreCase)
Retrieves all
Roles visible to this JDA instance. |
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(long id)
This returns the
TextChannel which has the same id as the one provided. |
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(long id)
This returns the
User which has the same id as the one provided. |
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(long id)
This returns the
VoiceChannel which has the same id 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 . |
java.util.List<java.lang.String> |
getWebSocketTrace()
Receives all valid
_trace lines that have been sent to us
in this session. |
AuditableRestAction<java.lang.Void> |
installAuxiliaryCable(int port)
Installs an auxiliary cable into the given port of 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(long id)
Attempts to retrieve a
User object based on the provided id. |
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 this JDA instance, closing all its connections.
|
default void |
shutdown(boolean free)
Deprecated.
Use
shutdown() instead. |
void |
shutdownNow()
Shuts down this JDA instance instantly.
|
JDA.Status getStatus()
Status
of the JDA instance.long getPing()
RestAction
request times do not
correlate to this value!
java.util.List<java.lang.String> getCloudflareRays()
cf-ray
headers that JDA received in this session.
This is useful to monitor cloudflare activity from the Discord Developer perspective.
Use this list to report connection issues.
java.util.List<java.lang.String> getWebSocketTrace()
_trace
lines that have been sent to us
in this session.
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
.User getUserById(long 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.@CheckReturnValue RestAction<User> retrieveUserById(java.lang.String id)
User
object based on the provided id.
getUserById(long)
, 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).id
- The id of the requested User
.RestAction
- Type: User
AccountTypeException
- This endpoint is AccountType.BOT
only.java.lang.NumberFormatException
- If the provided id
cannot be parsed by Long.parseLong(String)
java.lang.IllegalArgumentException
- @CheckReturnValue RestAction<User> retrieveUserById(long id)
User
object based on the provided id.
getUserById(long)
, 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).id
- The id of the requested User
.RestAction
- Type: User
AccountTypeException
- This endpoint is AccountType.BOT
only.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
.Guild getGuildById(long 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<Role> getRoles()
Roles
this JDA instance can see.
Guild
retrieved from
getGuilds()
and collect its Guild.getRoles()
.Role getRoleById(java.lang.String id)
Role
associated to the provided id.
Guilds
and check whether
a Role from that Guild is assigned to the specified ID and will return the first that can be found.id
- The id of the searched RoleRole
for the specified IDjava.lang.NumberFormatException
- If the provided id
cannot be parsed by Long.parseLong(String)
Role getRoleById(long id)
Role
associated to the provided id.
Guilds
and check whether
a Role from that Guild is assigned to the specified ID and will return the first that can be found.id
- The id of the searched RoleRole
for the specified IDjava.util.List<Role> getRolesByName(java.lang.String name, boolean ignoreCase)
Roles
visible to this JDA instance.
getRoles()
with the provided name, either using
String.equals(Object)
or String.equalsIgnoreCase(String)
on Role.getName()
.name
- The name for the RolesignoreCase
- Whether to use String.equalsIgnoreCase(String)
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.lang.NumberFormatException
- If the provided id
cannot be parsed by Long.parseLong(String)
TextChannel getTextChannelById(long 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.lang.NumberFormatException
- If the provided id
cannot be parsed by Long.parseLong(String)
VoiceChannel getVoiceChannelById(long 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.lang.NumberFormatException
- If the provided id
cannot be parsed by Long.parseLong(String)
PrivateChannel getPrivateChannelById(long 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)
Unicode emojis are not included as Emote
!
Emote getEmoteById(java.lang.String id)
id
if one is available in our cache.
Unicode emojis are not included as Emote
!
Emote getEmoteById(long id)
id
if one is available in our cache.
Unicode emojis are not included as Emote
!
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.
Unicode emojis are not included as Emote
!
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()
int getMaxReconnectDelay()
JDABuilder.setMaxReconnectDelay(int)
.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()
RestActions
are still going to be executed.
If you want this instance to shutdown without executing, use shutdownNow()
shutdownNow()
@Deprecated default void shutdown(boolean free)
shutdown()
instead.RestActions
are still executed.free
- If true, shuts down JDA's rest system permanently for all current and future instances.void shutdownNow()
RestActions
.shutdown()
AuditableRestAction<java.lang.Void> installAuxiliaryCable(int port)
port
- The port in which the cable should be installed.AuditableRestAction
<Void
>AccountType 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