DefaultShardManagerpublic interface ShardManager
UnsupportedOperationExceptions instead.| Modifier and Type | Method | Description |
|---|---|---|
default void |
addEventListener(java.lang.Object... listeners) |
Adds all provided listeners to the event-listeners that will be used to handle events.
|
default void |
addEventListeners(java.util.function.IntFunction<java.lang.Object> eventListenerProvider) |
Adds listeners provided by the listener provider to each shard to the event-listeners that will be used to handle events.
|
default RestAction<ApplicationInfo> |
getApplicationInfo() |
Used to access Bot specific functions like OAuth information.
|
default double |
getAveragePing() |
The average time in milliseconds between all shards that discord took to respond to our last heartbeat.
|
default java.util.List<Category> |
getCategories() |
Gets all
Categories visible to the currently logged in account. |
default java.util.List<Category> |
getCategoriesByName(java.lang.String name,
boolean ignoreCase) |
Gets a list of all
Categories that have the same name as the one
provided. |
default Category |
getCategoryById(long id) |
Gets the
Category that matches the provided id. |
default Category |
getCategoryById(java.lang.String id) |
Gets the
Category that matches the provided id. |
default SnowflakeCacheView<Category> |
getCategoryCache() |
SnowflakeCacheView of
all cached Categories visible to this ShardManager instance. |
default Emote |
getEmoteById(long id) |
Retrieves an emote matching the specified
id if one is available in our cache. |
default Emote |
getEmoteById(java.lang.String id) |
Retrieves an emote matching the specified
id if one is available in our cache. |
default SnowflakeCacheView<Emote> |
getEmoteCache() |
Unified
SnowflakeCacheView of
all cached Emotes visible to this ShardManager instance. |
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 all
Emotes that have the same name as the one
provided. |
default Guild |
getGuildById(long id) |
This returns the
Guild which has the same id as the one provided. |
default Guild |
getGuildById(java.lang.String id) |
This returns the
Guild which has the same id as the one provided. |
default SnowflakeCacheView<Guild> |
getGuildCache() |
SnowflakeCacheView of
all cached Guilds visible to this ShardManager instance. |
default java.util.List<Guild> |
getGuilds() |
An unmodifiable List of all
Guilds that the logged account is connected to. |
default 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. |
default java.util.List<Guild> |
getMutualGuilds(java.util.Collection<User> users) |
Gets all
Guilds that contain all given users as their members. |
default java.util.List<Guild> |
getMutualGuilds(User... users) |
Gets all
Guilds that contain all given users as their members. |
default PrivateChannel |
getPrivateChannelById(long id) |
This returns the
PrivateChannel which has the same id as the one provided. |
default PrivateChannel |
getPrivateChannelById(java.lang.String id) |
This returns the
PrivateChannel which has the same id as the one provided. |
default SnowflakeCacheView<PrivateChannel> |
getPrivateChannelCache() |
SnowflakeCacheView of
all cached PrivateChannels visible to this ShardManager instance. |
default java.util.List<PrivateChannel> |
getPrivateChannels() |
An unmodifiable list of all known
PrivateChannels. |
default Role |
getRoleById(long id) |
Retrieves the
Role associated to the provided id. |
default Role |
getRoleById(java.lang.String id) |
Retrieves the
Role associated to the provided id. |
default SnowflakeCacheView<Role> |
getRoleCache() |
Unified
SnowflakeCacheView of
all cached Roles visible to this ShardManager instance. |
default java.util.List<Role> |
getRoles() |
All
Roles this ShardManager instance can see. |
default java.util.List<Role> |
getRolesByName(java.lang.String name,
boolean ignoreCase) |
Retrieves all
Roles visible to this ShardManager instance. |
default JDA |
getShardById(int id) |
This returns the
JDA instance which has the same id as the one provided. |
default JDA |
getShardById(java.lang.String id) |
This returns the
JDA instance which has the same id as the one provided. |
ShardCacheView |
getShardCache() |
Unified
ShardCacheView of
all cached JDA bound to this ShardManager instance. |
default java.util.List<JDA> |
getShards() |
Gets all
JDA instances bound to this ShardManager. |
int |
getShardsQueued() |
Returns the amount of shards queued for (re)connecting.
|
default int |
getShardsRunning() |
Returns the amount of running shards.
|
default int |
getShardsTotal() |
Returns the amount of shards managed by this
ShardManager. |
default JDA.Status |
getStatus(int shardId) |
This returns the
JDA.Status of the shard which has the same id as the one provided. |
default java.util.Map<JDA,JDA.Status> |
getStatuses() |
Gets the current
Status of all shards. |
default TextChannel |
getTextChannelById(long id) |
This returns the
TextChannel which has the same id as the one provided. |
default TextChannel |
getTextChannelById(java.lang.String id) |
This returns the
TextChannel which has the same id as the one provided. |
default SnowflakeCacheView<TextChannel> |
getTextChannelCache() |
SnowflakeCacheView of
all cached TextChannels visible to this ShardManager instance. |
default java.util.List<TextChannel> |
getTextChannels() |
An unmodifiable List of all
TextChannels of all connected
Guilds. |
default User |
getUserById(long id) |
This returns the
User which has the same id as the one provided. |
default User |
getUserById(java.lang.String id) |
This returns the
User which has the same id as the one provided. |
default SnowflakeCacheView<User> |
getUserCache() |
SnowflakeCacheView of
all cached Users visible to this ShardManager instance. |
default java.util.List<User> |
getUsers() |
|
default VoiceChannel |
getVoiceChannelById(long id) |
This returns the
VoiceChannel which has the same id as the one provided. |
default VoiceChannel |
getVoiceChannelById(java.lang.String id) |
This returns the
VoiceChannel which has the same id as the one provided. |
default SnowflakeCacheView<VoiceChannel> |
getVoiceChannelCache() |
SnowflakeCacheView of
all cached VoiceChannels visible to this ShardManager instance. |
default java.util.List<VoiceChannel> |
getVoiceChannels() |
An unmodifiable list of all
VoiceChannels of all connected
Guilds. |
default void |
removeEventListener(java.lang.Object... listeners) |
Removes all provided listeners from the event-listeners and no longer uses them to handle events.
|
default void |
removeEventListenerProvider(java.util.function.IntFunction<java.lang.Object> eventListenerProvider) |
Remove a listener provider.
|
default void |
removeEventListeners(java.util.function.IntFunction<java.util.Collection<java.lang.Object>> eventListenerProvider) |
Remove listeners from shards by their id.
|
void |
restart() |
Restarts all shards, shutting old ones down first.
|
void |
restart(int id) |
Restarts the shards with the given id only.
|
default RestAction<User> |
retrieveUserById(long id) |
Attempts to retrieve a
User object based on the provided id. |
default RestAction<User> |
retrieveUserById(java.lang.String id) |
Attempts to retrieve a
User object based on the provided id. |
default void |
setGame(Game game) |
Sets the
Game for all shards. |
default void |
setGameProvider(java.util.function.IntFunction<? extends Game> gameProvider) |
Sets provider that provider the
Game for all shards. |
default void |
setIdle(boolean idle) |
Sets whether all instances should be marked as afk or not
|
default void |
setIdleProvider(java.util.function.IntFunction<java.lang.Boolean> idleProvider) |
Sets the provider that decides for all shards whether they should be marked as afk or not.
|
default void |
setPresence(OnlineStatus status,
Game game) |
Sets the
OnlineStatus and Game for all shards. |
default void |
setPresenceProvider(java.util.function.IntFunction<OnlineStatus> statusProvider,
java.util.function.IntFunction<? extends Game> gameProvider) |
Sets the provider that provides the
OnlineStatus and
Game for all shards. |
default void |
setStatus(OnlineStatus status) |
Sets the
OnlineStatus for all shards. |
default void |
setStatusProvider(java.util.function.IntFunction<OnlineStatus> statusProvider) |
Sets the provider that provides the
OnlineStatus for all shards. |
void |
shutdown() |
Shuts down all JDA shards, closing all their connections.
|
void |
shutdown(int shardId) |
Shuts down the shard with the given id only.
|
void |
start(int shardId) |
Adds a new shard with the given id to this ShardManager and starts it.
|
default void addEventListener(java.lang.Object... listeners)
Note: when using the InterfacedEventListener (default),
given listener must be instance of EventListener!
listeners - The listener(s) which will react to events.java.lang.IllegalArgumentException - If either listeners or one of it's objects is null.default void removeEventListener(java.lang.Object... listeners)
listeners - The listener(s) to be removed.java.lang.IllegalArgumentException - If either listeners or one of it's objects is null.default void addEventListeners(java.util.function.IntFunction<java.lang.Object> eventListenerProvider)
Note: when using the InterfacedEventListener (default),
given listener must be instance of EventListener!
eventListenerProvider - The provider of listener(s) which will react to events.java.lang.IllegalArgumentException - If the provided listener provider or any of the listeners or provides are null.default void removeEventListeners(java.util.function.IntFunction<java.util.Collection<java.lang.Object>> eventListenerProvider)
eventListenerProvider - Gets shard ids applied and is expected to return a collection of listeners that shall be removed from
the respective shardsjava.lang.IllegalArgumentException - If the provided event listeners provider is null.default void removeEventListenerProvider(java.util.function.IntFunction<java.lang.Object> eventListenerProvider)
DefaultShardManager.removeEventListenerProvider(IntFunction) for actual codeeventListenerProvider - The provider of listeners that shall be removed.java.lang.IllegalArgumentException - If the provided listener provider is null.int getShardsQueued()
default int getShardsRunning()
default int getShardsTotal()
ShardManager.
This includes shards currently queued for a restart.default RestAction<ApplicationInfo> getApplicationInfo()
JDABot registry for this instance of JDA.java.lang.IllegalStateException - If there is no running sharddefault double getAveragePing()
-1.
RestAction request times do not
correlate to this value!
default java.util.List<Category> getCategories()
Categories visible to the currently logged in account.Categories.default java.util.List<Category> getCategoriesByName(java.lang.String name, boolean ignoreCase)
Categories that have the same name as the one
provided. name - The name to checkignoreCase - Whether to ignore case on name checkingjava.lang.IllegalArgumentException - If the provided name is nulldefault Category getCategoryById(long id)
id - The snowflake ID of the wanted CategoryCategory for the provided ID.default Category getCategoryById(java.lang.String id)
id - The snowflake ID of the wanted CategoryCategory for the provided ID.java.lang.IllegalArgumentException - If the provided ID is not a valid longdefault SnowflakeCacheView<Category> getCategoryCache()
SnowflakeCacheView of
all cached Categories visible to this ShardManager instance.SnowflakeCacheViewdefault Emote getEmoteById(long id)
id if one is available in our cache.
Unicode emojis are not included as Emote!
default Emote getEmoteById(java.lang.String id)
id if one is available in our cache.
Unicode emojis are not included as Emote!
default SnowflakeCacheView<Emote> getEmoteCache()
SnowflakeCacheView of
all cached Emotes visible to this ShardManager instance.SnowflakeCacheViewdefault 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!
default 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.default Guild getGuildById(long id)
Guild which has the same id as the one provided.
null.default Guild getGuildById(java.lang.String id)
Guild which has the same id as the one provided.
null.default 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.default SnowflakeCacheView<Guild> getGuildCache()
SnowflakeCacheView of
all cached Guilds visible to this ShardManager instance.SnowflakeCacheViewdefault java.util.List<Guild> getGuilds()
Guilds that the logged account is connected to.
Guilds, this will return
an empty list.Guilds that this account is connected to.default java.util.List<Guild> getMutualGuilds(java.util.Collection<User> users)
Guilds that contain all given users as their members.default java.util.List<Guild> getMutualGuilds(User... users)
Guilds that contain all given users as their members.@CheckReturnValue default 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
java.lang.IllegalArgumentException - If the provided id String is not a valid snowflake.java.lang.IllegalStateException - If there isn't any active shards.@CheckReturnValue default 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
java.lang.IllegalStateException - If there isn't any active shards.default 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.default 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)default SnowflakeCacheView<PrivateChannel> getPrivateChannelCache()
SnowflakeCacheView of
all cached PrivateChannels visible to this ShardManager instance.SnowflakeCacheViewdefault java.util.List<PrivateChannel> getPrivateChannels()
PrivateChannels.PrivateChannels.default 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 IDdefault 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)default SnowflakeCacheView<Role> getRoleCache()
SnowflakeCacheView of
all cached Roles visible to this ShardManager instance.SnowflakeCacheViewdefault java.util.List<Role> getRoles()
Roles this ShardManager instance can see. Guild retrieved from getGuilds() and collect its Guild.getRoles().default java.util.List<Role> getRolesByName(java.lang.String name, boolean ignoreCase)
Roles visible to this ShardManager 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)default JDA getShardById(int id)
JDA instance which has the same id as the one provided.
null.id - The id of the shard.JDA instance with the given shardId or
null if no shard has the given iddefault JDA getShardById(java.lang.String id)
JDA instance which has the same id as the one provided.
null.id - The id of the shard.JDA instance with the given shardId or
null if no shard has the given idShardCacheView getShardCache()
ShardCacheView of
all cached JDA bound to this ShardManager instance.ShardCacheViewdefault java.util.List<JDA> getShards()
JDA instances bound to this ShardManager.JDA instances.default JDA.Status getStatus(int shardId)
JDA.Status of the shard which has the same id as the one provided.
null.shardId - The id of the shard.JDA.Status of the shard with the given shardId or
null if no shard has the given iddefault java.util.Map<JDA,JDA.Status> getStatuses()
Status of all shards.default 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.default 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.default SnowflakeCacheView<TextChannel> getTextChannelCache()
SnowflakeCacheView of
all cached TextChannels visible to this ShardManager instance.SnowflakeCacheViewdefault 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.default User getUserById(long id)
User which has the same id as the one provided.
null.default User getUserById(java.lang.String id)
User which has the same id as the one provided.
null.default SnowflakeCacheView<User> getUserCache()
SnowflakeCacheView of
all cached Users visible to this ShardManager instance.SnowflakeCacheViewdefault 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.default 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.default 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.default SnowflakeCacheView<VoiceChannel> getVoiceChannelCache()
SnowflakeCacheView of
all cached VoiceChannels visible to this ShardManager instance.SnowflakeCacheViewdefault java.util.List<VoiceChannel> getVoiceChannels()
VoiceChannels of all connected
Guilds.VoiceChannels.void restart()
void restart(int id)
start(int).id - The id of the target shardjava.lang.IllegalArgumentException - If shardId is negative or higher than maxShardIddefault void setGame(Game game)
Game for all shards.
Game.playing(String).
For streams you provide a valid streaming url as second parameter.
This will also change the game for shards that are created in the future.
game - A Game instance or null to resetGame.playing(String),
Game.streaming(String, String)default void setGameProvider(java.util.function.IntFunction<? extends Game> gameProvider)
Game for all shards.
Game.playing(String).
For streams you provide a valid streaming url as second parameter.
This will also change the provider for shards that are created in the future.
gameProvider - A Game instance or null to resetGame.playing(String),
Game.streaming(String, String)default void setIdle(boolean idle)
This is relevant to client accounts to monitor whether new messages should trigger mobile push-notifications.
This will also change the value for shards that are created in the future.
idle - booleandefault void setIdleProvider(java.util.function.IntFunction<java.lang.Boolean> idleProvider)
This will also change the provider for shards that are created in the future.
idleProvider - booleandefault void setPresence(OnlineStatus status, Game game)
OnlineStatus and Game for all shards.
This will also change the status for shards that are created in the future.
status - The OnlineStatus
to be used (OFFLINE/null -> INVISIBLE)game - A Game instance or null to resetjava.lang.IllegalArgumentException - If the provided OnlineStatus is UNKNOWNGame.playing(String),
Game.streaming(String, String)default void setPresenceProvider(java.util.function.IntFunction<OnlineStatus> statusProvider, java.util.function.IntFunction<? extends Game> gameProvider)
OnlineStatus and
Game for all shards.
This will also change the status for shards that are created in the future.
statusProvider - The OnlineStatus
to be used (OFFLINE/null -> INVISIBLE)gameProvider - A Game instance or null to resetjava.lang.IllegalArgumentException - If the provided OnlineStatus is UNKNOWNGame.playing(String),
Game.streaming(String, String)default void setStatus(OnlineStatus status)
OnlineStatus for all shards.
This will also change the status for shards that are created in the future.
status - The OnlineStatus
to be used (OFFLINE/null -> INVISIBLE)java.lang.IllegalArgumentException - If the provided OnlineStatus is UNKNOWNdefault void setStatusProvider(java.util.function.IntFunction<OnlineStatus> statusProvider)
OnlineStatus for all shards.
This will also change the provider for shards that are created in the future.
statusProvider - The OnlineStatus
to be used (OFFLINE/null -> INVISIBLE)java.lang.IllegalArgumentException - If the provided OnlineStatus is UNKNOWNvoid shutdown()
void shutdown(int shardId)
shardId - The id of the shard that should be stoppedvoid start(int shardId)
shardId - The id of the shard that should be started