public class DefaultShardManagerBuilder
extends java.lang.Object
ShardManager
implementation.
A single DefaultShardManagerBuilder can be reused multiple times. Each call to build()
creates a new ShardManager
instance using the same information.
Constructor | Description |
---|---|
DefaultShardManagerBuilder() |
Creates a completely empty DefaultShardManagerBuilder.
|
Modifier and Type | Method | Description |
---|---|---|
DefaultShardManagerBuilder |
addEventListenerProvider(java.util.function.IntFunction<java.lang.Object> listenerProvider) |
Adds the provided listener provider to the list of listener providers that will be used to create listeners.
|
DefaultShardManagerBuilder |
addEventListenerProviders(java.util.Collection<java.util.function.IntFunction<java.lang.Object>> listenerProviders) |
Adds the provided listener providers to the list of listener providers that will be used to create listeners.
|
DefaultShardManagerBuilder |
addEventListeners(java.lang.Object... listeners) |
Adds all provided listeners to the list of listeners that will be used to populate the
DefaultShardManager object. |
DefaultShardManagerBuilder |
addEventListeners(java.util.Collection<java.lang.Object> listeners) |
Adds all provided listeners to the list of listeners that will be used to populate the
DefaultShardManager object. |
ShardManager |
build() |
Builds a new
ShardManager instance and uses the provided token to start the login process. |
DefaultShardManagerBuilder |
removeEventListenerProvider(java.util.function.IntFunction<java.lang.Object> listenerProvider) |
Removes the provided listener provider from the list of listener providers.
|
DefaultShardManagerBuilder |
removeEventListenerProviders(java.util.Collection<java.util.function.IntFunction<java.lang.Object>> listenerProviders) |
Removes all provided listener providers from the list of listener providers.
|
DefaultShardManagerBuilder |
removeEventListeners(java.lang.Object... listeners) |
Removes all provided listeners from the list of listeners.
|
DefaultShardManagerBuilder |
removeEventListeners(java.util.Collection<java.lang.Object> listeners) |
Removes all provided listeners from the list of listeners.
|
DefaultShardManagerBuilder |
setAudioEnabled(boolean enabled) |
Enables/Disables Voice functionality.
|
DefaultShardManagerBuilder |
setAudioSendFactory(IAudioSendFactory factory) |
Changes the factory used to create
IAudioSendSystem
objects which handle the sending loop for audio packets. |
DefaultShardManagerBuilder |
setAutoReconnect(boolean autoReconnect) |
Sets whether or not JDA should try to reconnect if a connection-error is encountered.
|
DefaultShardManagerBuilder |
setBulkDeleteSplittingEnabled(boolean enabled) |
If enabled, JDA will separate the bulk delete event into individual delete events, but this isn't as efficient as
handling a single event would be.
|
DefaultShardManagerBuilder |
setCallbackPool(java.util.concurrent.ExecutorService executor) |
Sets the
ExecutorService that should be used in
the JDA callback handler which mostly consists of RestAction callbacks. |
DefaultShardManagerBuilder |
setCallbackPool(java.util.concurrent.ExecutorService executor,
boolean automaticShutdown) |
Sets the
ExecutorService that should be used in
the JDA callback handler which mostly consists of RestAction callbacks. |
DefaultShardManagerBuilder |
setCallbackPoolProvider(ThreadPoolProvider<? extends java.util.concurrent.ExecutorService> provider) |
Sets the
ExecutorService that should be used in
the JDA callback handler which mostly consists of RestAction callbacks. |
DefaultShardManagerBuilder |
setCompressionEnabled(boolean enable) |
Enable stream-compression on the gateway connection,
this will decrease the amount of used bandwidth for the running bot instance
for the cost of a few extra cycles for decompression.
|
DefaultShardManagerBuilder |
setContextEnabled(boolean enable) |
Whether JDA should use a synchronized MDC context for all of its controlled threads.
|
DefaultShardManagerBuilder |
setContextMap(java.util.function.IntFunction<? extends java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.String>> provider) |
Sets the
MDC mappings provider to use in JDA. |
DefaultShardManagerBuilder |
setCorePoolSize(int size) |
Sets the core pool size for the global JDA
ScheduledExecutorService
which is used in various locations throughout the JDA instance created by this ShardManager. |
DefaultShardManagerBuilder |
setDisabledCacheFlags(java.util.EnumSet<CacheFlag> flags) |
Flags used to disable parts of the JDA cache to reduce the runtime memory footprint.
|
DefaultShardManagerBuilder |
setEnabledCacheFlags(java.util.EnumSet<CacheFlag> flags) |
Flags used to enable parts of the JDA cache to reduce the runtime memory footprint.
|
DefaultShardManagerBuilder |
setEnableShutdownHook(boolean enable) |
Enables/Disables the use of a Shutdown hook to clean up the ShardManager and it's JDA instances.
|
DefaultShardManagerBuilder |
setEventManager(IEventManager manager) |
Deprecated.
Use
setEventManagerProvider(IntFunction) instead |
DefaultShardManagerBuilder |
setEventManagerProvider(java.util.function.IntFunction<? extends IEventManager> eventManagerProvider) |
Sets a provider to change the internally used EventManager.
|
DefaultShardManagerBuilder |
setGame(Game game) |
Sets the
Game for our session. |
DefaultShardManagerBuilder |
setGameProvider(java.util.function.IntFunction<? extends Game> gameProvider) |
Sets the
Game for our session. |
DefaultShardManagerBuilder |
setGatewayPool(java.util.concurrent.ScheduledExecutorService pool) |
Sets the
ScheduledExecutorService that should be used for
the JDA main WebSocket workers. |
DefaultShardManagerBuilder |
setGatewayPool(java.util.concurrent.ScheduledExecutorService pool,
boolean automaticShutdown) |
Sets the
ScheduledExecutorService that should be used for
the JDA main WebSocket workers. |
DefaultShardManagerBuilder |
setGatewayPoolProvider(ThreadPoolProvider<? extends java.util.concurrent.ScheduledExecutorService> provider) |
Sets the
ScheduledExecutorService that should be used for
the JDA main WebSocket workers. |
DefaultShardManagerBuilder |
setHttpClient(okhttp3.OkHttpClient client) |
Sets the
OkHttpClient that will be used by JDAs requester. |
DefaultShardManagerBuilder |
setHttpClientBuilder(okhttp3.OkHttpClient.Builder builder) |
Sets the
Builder that will be used by JDA's requester. |
DefaultShardManagerBuilder |
setIdle(boolean idle) |
Sets whether or not we should mark our sessions as afk
This value can be changed at any time using DefaultShardManager#setIdleProvider(boolean) . |
DefaultShardManagerBuilder |
setIdleProvider(java.util.function.IntFunction<java.lang.Boolean> idleProvider) |
Sets whether or not we should mark our sessions as afk
This value can be changed at any time using DefaultShardManager#setIdleProvider(boolean) . |
DefaultShardManagerBuilder |
setMaxReconnectDelay(int maxReconnectDelay) |
Sets the maximum amount of time that JDA will back off to wait when attempting to reconnect the MainWebsocket.
|
DefaultShardManagerBuilder |
setRateLimitPool(java.util.concurrent.ScheduledExecutorService pool) |
Sets the
ScheduledExecutorService that should be used in
the JDA rate-limit handler. |
DefaultShardManagerBuilder |
setRateLimitPool(java.util.concurrent.ScheduledExecutorService pool,
boolean automaticShutdown) |
Sets the
ScheduledExecutorService that should be used in
the JDA rate-limit handler. |
DefaultShardManagerBuilder |
setRateLimitPoolProvider(ThreadPoolProvider<? extends java.util.concurrent.ScheduledExecutorService> provider) |
Sets the
ScheduledExecutorService provider that should be used in
the JDA rate-limit handler. |
DefaultShardManagerBuilder |
setRequestTimeoutRetry(boolean retryOnTimeout) |
Whether the Requester should retry when
a
SocketTimeoutException occurs. |
DefaultShardManagerBuilder |
setSessionController(SessionController controller) |
Sets the
SessionController
for the resulting ShardManager instance. |
DefaultShardManagerBuilder |
setShards(int... shardIds) |
Sets the list of shards the
DefaultShardManager should contain. |
DefaultShardManagerBuilder |
setShards(int minShardId,
int maxShardId) |
Sets the range of shards the
DefaultShardManager should contain. |
DefaultShardManagerBuilder |
setShards(java.util.Collection<java.lang.Integer> shardIds) |
Sets the range of shards the
DefaultShardManager should contain. |
DefaultShardManagerBuilder |
setShardsTotal(int shardsTotal) |
This will set the total amount of shards the
DefaultShardManager should use. |
DefaultShardManagerBuilder |
setStatus(OnlineStatus status) |
Sets the
OnlineStatus our connection will display. |
DefaultShardManagerBuilder |
setStatusProvider(java.util.function.IntFunction<OnlineStatus> statusProvider) |
Sets the
OnlineStatus our connection will display. |
DefaultShardManagerBuilder |
setThreadFactory(java.util.concurrent.ThreadFactory threadFactory) |
Sets the
ThreadFactory that will be used by the internal executor
of the ShardManager. |
DefaultShardManagerBuilder |
setToken(java.lang.String token) |
Sets the token that will be used by the
ShardManager instance to log in when
build() is called. |
DefaultShardManagerBuilder |
setUseShutdownNow(boolean useShutdownNow) |
Whether the
ShardManager should use
JDA#shutdownNow() instead of
JDA#shutdown() to shutdown it's shards. |
DefaultShardManagerBuilder |
setWebsocketFactory(com.neovisionaries.ws.client.WebSocketFactory factory) |
Sets the
WebSocketFactory that will be used by JDA's websocket client. |
public DefaultShardManagerBuilder()
setToken(String)
before calling build()
.public DefaultShardManagerBuilder setEnabledCacheFlags(java.util.EnumSet<CacheFlag> flags)
setDisabledCacheFlags(EnumSet)
instead
for backwards compatibility. We might add more flags in the future which you then effectively disable
when updating and not changing your setting here.flags
- EnumSet containing the flags for cache services that should be enabledpublic DefaultShardManagerBuilder setDisabledCacheFlags(java.util.EnumSet<CacheFlag> flags)
setEnabledCacheFlags(EnumSet.complementOf(flags))
flags
- EnumSet containing the flags for cache services that should be disabledpublic DefaultShardManagerBuilder setSessionController(SessionController controller)
SessionController
for the resulting ShardManager instance. This can be used to sync behaviour and state between shards
of a bot and should be one and the same instance on all builders for the shards.controller
- The SessionController
to useSessionControllerAdapter
public DefaultShardManagerBuilder setContextMap(java.util.function.IntFunction<? extends java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.String>> provider)
MDC
mappings provider to use in JDA.
jda.shard
context with the format [SHARD_ID / TOTAL]
where SHARD_ID
and TOTAL
are the shard configuration.
Additionally it will provide context for the id via jda.shard.id
and the total via jda.shard.total
.
The manager will call this with a shardId and it is recommended to provide a different context map for each shard!
This automatically switches setContextEnabled(boolean)
to true if the provided function is not null!
provider
- The provider for modifiable context maps to use in JDA, or null
to resetpublic DefaultShardManagerBuilder setContextEnabled(boolean enable)
true
enable
- True, if JDA should provide an MDC context mapsetContextMap(java.util.function.IntFunction)
public DefaultShardManagerBuilder setCompressionEnabled(boolean enable)
We recommend to keep this enabled unless you have issues with the decompression
This mode might become obligatory in a future version, do not rely on this switch to stay.
enable
- True, if the gateway connection should use compressionpublic DefaultShardManagerBuilder addEventListeners(java.lang.Object... listeners)
DefaultShardManager
object.
InterfacedEventListener
by default.
AnnotatedEventManager
,
use setEventManagerProvider(id -> new AnnotatedEventManager())
.
Note: When using the InterfacedEventListener
(default),
given listener(s) must be instance of EventListener
!
listeners
- The listener(s) to add to the list.JDA.addEventListener(Object...)
public DefaultShardManagerBuilder addEventListeners(java.util.Collection<java.lang.Object> listeners)
DefaultShardManager
object.
InterfacedEventListener
by default.
AnnotatedEventManager
,
use setEventManager(id -> new AnnotatedEventManager())
.
Note: When using the InterfacedEventListener
(default),
given listener(s) must be instance of EventListener
!
listeners
- The listener(s) to add to the list.JDA.addEventListener(Object...)
public DefaultShardManagerBuilder removeEventListeners(java.lang.Object... listeners)
listeners
- The listener(s) to remove from the list.JDA.removeEventListener(Object...)
public DefaultShardManagerBuilder removeEventListeners(java.util.Collection<java.lang.Object> listeners)
listeners
- The listener(s) to remove from the list.JDA.removeEventListener(Object...)
public DefaultShardManagerBuilder addEventListenerProvider(java.util.function.IntFunction<java.lang.Object> listenerProvider)
InterfacedEventListener
by default.
AnnotatedEventManager
,
use setEventManager(id -> new AnnotatedEventManager())
.
Note: When using the InterfacedEventListener
(default),
given listener(s) must be instance of EventListener
!
listenerProvider
- The listener provider to add to the list of listener providers.public DefaultShardManagerBuilder addEventListenerProviders(java.util.Collection<java.util.function.IntFunction<java.lang.Object>> listenerProviders)
InterfacedEventListener
by default.
AnnotatedEventManager
,
use setEventManager(id -> new AnnotatedEventManager())
.
Note: When using the InterfacedEventListener
(default),
given listener(s) must be instance of EventListener
!
listenerProviders
- The listener provider to add to the list of listener providers.public DefaultShardManagerBuilder removeEventListenerProvider(java.util.function.IntFunction<java.lang.Object> listenerProvider)
listenerProvider
- The listener provider to remove from the list of listener providers.public DefaultShardManagerBuilder removeEventListenerProviders(java.util.Collection<java.util.function.IntFunction<java.lang.Object>> listenerProviders)
listenerProviders
- The listener provider(s) to remove from the list of listener providers.public DefaultShardManagerBuilder setAudioEnabled(boolean enabled)
Default: true (enabled)
enabled
- True - enables voice support.public DefaultShardManagerBuilder setAudioSendFactory(IAudioSendFactory factory)
IAudioSendSystem
objects which handle the sending loop for audio packets.
DefaultSendFactory
.factory
- The new IAudioSendFactory
to be used
when creating new IAudioSendSystem
objects.public DefaultShardManagerBuilder setAutoReconnect(boolean autoReconnect)
autoReconnect
- If true - enables autoReconnectpublic DefaultShardManagerBuilder setBulkDeleteSplittingEnabled(boolean enabled)
MessageBulkDeleteEvent
.
Default: true (enabled)
enabled
- True - The MESSAGE_DELETE_BULK will be split into multiple individual MessageDeleteEvents.public DefaultShardManagerBuilder setCorePoolSize(int size)
ScheduledExecutorService
which is used in various locations throughout the JDA instance created by this ShardManager. (Default: 5)
setRateLimitPool(ScheduledExecutorService)
or setRateLimitPoolProvider(ThreadPoolProvider)
.size
- The core pool size for the global JDA executorjava.lang.IllegalArgumentException
- If the specified core pool size is not positivepublic DefaultShardManagerBuilder setEnableShutdownHook(boolean enable)
Default: true (enabled)
enable
- True (default) - use shutdown hook to clean up the ShardManager and it's JDA instances if the Java program is closed.@Deprecated @DeprecatedSince("3.8.1") @ReplaceWith("setEventManagerProvider((id) -> manager)") public DefaultShardManagerBuilder setEventManager(IEventManager manager)
setEventManagerProvider(IntFunction)
insteadInterfacedEventManager
which uses the Interface
EventListener
(tip: use the ListenerAdapter
).
AnnotatedEventManager
which uses the Annotation
@SubscribeEvent
to mark the methods that listen for events.IEventManager
).manager
- The new IEventManager
to use.public DefaultShardManagerBuilder setEventManagerProvider(java.util.function.IntFunction<? extends IEventManager> eventManagerProvider)
InterfacedEventManager
which uses the Interface
EventListener
(tip: use the ListenerAdapter
).
AnnotatedEventManager
which uses the Annotation
@SubscribeEvent
to mark the methods that listen for events.IEventManager
).eventManagerProvider
- A supplier for the new IEventManager
to use.public DefaultShardManagerBuilder setGame(Game game)
Game
for our session.
Presence
from a JDA instance.
Hint: You can create a Game
object using
Game.playing(String)
or
Game.streaming(String, String)
Game.streaming(String, String)}.
game
- An instance of Game
(null allowed)Presence.setGame(Game)
public DefaultShardManagerBuilder setGameProvider(java.util.function.IntFunction<? extends Game> gameProvider)
Game
for our session.
Presence
from a JDA instance.
Hint: You can create a Game
object using
Game.playing(String)
or
Game.streaming(String, String)
.
gameProvider
- An instance of Game
(null allowed)Presence.setGame(Game)
public DefaultShardManagerBuilder setIdle(boolean idle)
DefaultShardManager#setIdleProvider(boolean)
.idle
- boolean value that will be provided with our IDENTIFY packages to mark our sessions as afk or not. (default false)Presence.setIdle(boolean)
public DefaultShardManagerBuilder setIdleProvider(java.util.function.IntFunction<java.lang.Boolean> idleProvider)
DefaultShardManager#setIdleProvider(boolean)
.idleProvider
- boolean value that will be provided with our IDENTIFY packages to mark our sessions as afk or not. (default false)Presence.setIdle(boolean)
public DefaultShardManagerBuilder setStatus(OnlineStatus status)
OnlineStatus
our connection will display.
Presence
from a JDA instance.
Note:This will not take affect for AccountType.CLIENT
if the statusProvider specified in the user_settings is not "online" as it is overriding our identify statusProvider.
status
- Not-null OnlineStatus (default online)java.lang.IllegalArgumentException
- if the provided OnlineStatus is null or UNKNOWN
Presence.setStatusProvider(OnlineStatus)
public DefaultShardManagerBuilder setStatusProvider(java.util.function.IntFunction<OnlineStatus> statusProvider)
OnlineStatus
our connection will display.
Presence
from a JDA instance.
Note:This will not take affect for AccountType.CLIENT
if the statusProvider specified in the user_settings is not "online" as it is overriding our identify statusProvider.
statusProvider
- Not-null OnlineStatus (default online)java.lang.IllegalArgumentException
- if the provided OnlineStatus is null or UNKNOWN
Presence.setStatusProvider(OnlineStatus)
public DefaultShardManagerBuilder setThreadFactory(java.util.concurrent.ThreadFactory threadFactory)
ThreadFactory
that will be used by the internal executor
of the ShardManager.
Note: This will not affect Threads created by any JDA instance.
threadFactory
- The ThreadFactory or null
to reset to the default value.public DefaultShardManagerBuilder setHttpClientBuilder(okhttp3.OkHttpClient.Builder builder)
Builder
that will be used by JDA's requester.
This can be used to set things such as connection timeout and proxy.builder
- The new OkHttpClient.Builder
to use.public DefaultShardManagerBuilder setHttpClient(okhttp3.OkHttpClient client)
OkHttpClient
that will be used by JDAs requester.
client
- The new OkHttpClient
to usepublic DefaultShardManagerBuilder setRateLimitPool(java.util.concurrent.ScheduledExecutorService pool)
ScheduledExecutorService
that should be used in
the JDA rate-limit handler. Changing this can drastically change the JDA behavior for RestAction execution
and should be handled carefully. Only change this pool if you know what you're doing.
setRateLimitPoolProvider(ThreadPoolProvider)
.
setRateLimiPool(executor, true)
pool
- The thread-pool to use for rate-limit handlingpublic DefaultShardManagerBuilder setRateLimitPool(java.util.concurrent.ScheduledExecutorService pool, boolean automaticShutdown)
ScheduledExecutorService
that should be used in
the JDA rate-limit handler. Changing this can drastically change the JDA behavior for RestAction execution
and should be handled carefully. Only change this pool if you know what you're doing.
setRateLimitPoolProvider(ThreadPoolProvider)
.pool
- The thread-pool to use for rate-limit handlingautomaticShutdown
- Whether JDA.shutdown()
should automatically shutdown this poolpublic DefaultShardManagerBuilder setRateLimitPoolProvider(ThreadPoolProvider<? extends java.util.concurrent.ScheduledExecutorService> provider)
ScheduledExecutorService
provider that should be used in
the JDA rate-limit handler. Changing this can drastically change the JDA behavior for RestAction execution
and should be handled carefully. Only change this pool if you know what you're doing.provider
- The thread-pool provider to use for rate-limit handlingpublic DefaultShardManagerBuilder setGatewayPool(java.util.concurrent.ScheduledExecutorService pool)
ScheduledExecutorService
that should be used for
the JDA main WebSocket workers.
setGatewayPoolProvider(ThreadPoolProvider)
.
setGatewayPoolProvider(pool, true)
pool
- The thread-pool to use for main WebSocket workerspublic DefaultShardManagerBuilder setGatewayPool(java.util.concurrent.ScheduledExecutorService pool, boolean automaticShutdown)
ScheduledExecutorService
that should be used for
the JDA main WebSocket workers.
setGatewayPoolProvider(ThreadPoolProvider)
.pool
- The thread-pool to use for main WebSocket workersautomaticShutdown
- Whether JDA.shutdown()
should automatically shutdown this poolpublic DefaultShardManagerBuilder setGatewayPoolProvider(ThreadPoolProvider<? extends java.util.concurrent.ScheduledExecutorService> provider)
ScheduledExecutorService
that should be used for
the JDA main WebSocket workers.
provider
- The thread-pool provider to use for main WebSocket workerspublic DefaultShardManagerBuilder setCallbackPool(java.util.concurrent.ExecutorService executor)
ExecutorService
that should be used in
the JDA callback handler which mostly consists of RestAction
callbacks.
By default JDA will use ForkJoinPool.commonPool()
setCallbackPool(executor, true)
executor
- The thread-pool to use for callback handlingpublic DefaultShardManagerBuilder setCallbackPool(java.util.concurrent.ExecutorService executor, boolean automaticShutdown)
ExecutorService
that should be used in
the JDA callback handler which mostly consists of RestAction
callbacks.
By default JDA will use ForkJoinPool.commonPool()
executor
- The thread-pool to use for callback handlingautomaticShutdown
- Whether JDA.shutdown()
should automatically shutdown this poolpublic DefaultShardManagerBuilder setCallbackPoolProvider(ThreadPoolProvider<? extends java.util.concurrent.ExecutorService> provider)
ExecutorService
that should be used in
the JDA callback handler which mostly consists of RestAction
callbacks.
By default JDA will use ForkJoinPool.commonPool()
provider
- The thread-pool provider to use for callback handlingpublic DefaultShardManagerBuilder setMaxReconnectDelay(int maxReconnectDelay)
maxReconnectDelay
- The maximum amount of time that JDA will wait between reconnect attempts in seconds.java.lang.IllegalArgumentException
- Thrown if the provided maxReconnectDelay
is less than 32.public DefaultShardManagerBuilder setRequestTimeoutRetry(boolean retryOnTimeout)
SocketTimeoutException
occurs.
true
This value can be changed at any time with JDA.setRequestTimeoutRetry(boolean)
!
retryOnTimeout
- True, if the Request should retry once on a socket timeoutpublic DefaultShardManagerBuilder setShards(int... shardIds)
DefaultShardManager
should contain.
This does not have any effect if the total shard count is set to -1
(get recommended shards from discord).
shardIds
- The list of shard idspublic DefaultShardManagerBuilder setShards(int minShardId, int maxShardId)
DefaultShardManager
should contain.
This is useful if you want to split your shards between multiple JVMs or servers.
This does not have any effect if the total shard count is set to -1
(get recommended shards from discord).
minShardId
- The lowest shard id the DefaultShardManager should containmaxShardId
- The highest shard id the DefaultShardManager should containjava.lang.IllegalArgumentException
- If either minShardId is negative, maxShardId is lower than shardsTotal or
minShardId is lower than or equal to maxShardIdpublic DefaultShardManagerBuilder setShards(java.util.Collection<java.lang.Integer> shardIds)
DefaultShardManager
should contain.
This is useful if you want to split your shards between multiple JVMs or servers.
This does not have any effect if the total shard count is set to -1
(get recommended shards from discord).
shardIds
- The list of shard idsjava.lang.IllegalArgumentException
- If either minShardId is negative, maxShardId is lower than shardsTotal or
minShardId is lower than or equal to maxShardIdpublic DefaultShardManagerBuilder setShardsTotal(int shardsTotal)
DefaultShardManager
should use.
If this is set to -1
JDA will automatically retrieve the recommended amount of shards from discord (default behavior).
shardsTotal
- The number of overall shards or -1
if JDA should use the recommended amount from discord.setShards(int, int)
public DefaultShardManagerBuilder setToken(java.lang.String token)
ShardManager
instance to log in when
build()
is called.
To get a bot token:
token
token
- The token of the account that you would like to login with.java.lang.IllegalArgumentException
- If the token is either null or emptypublic DefaultShardManagerBuilder setUseShutdownNow(boolean useShutdownNow)
ShardManager
should use
JDA#shutdownNow()
instead of
JDA#shutdown()
to shutdown it's shards.
false
useShutdownNow
- Whether the ShardManager should use JDA#shutdown() or notJDA.shutdown()
,
JDA.shutdownNow()
public DefaultShardManagerBuilder setWebsocketFactory(com.neovisionaries.ws.client.WebSocketFactory factory)
WebSocketFactory
that will be used by JDA's websocket client.
This can be used to set things such as connection timeout and proxy.factory
- The new WebSocketFactory
to use.public ShardManager build() throws javax.security.auth.login.LoginException, java.lang.IllegalArgumentException
ShardManager
instance and uses the provided token to start the login process.
ShardManager
has not
finished loading, thus many ShardManager
methods have the chance to return incorrect information.
Note that this method is async and as such will not block until all shards are started.
ShardManager
instance that has started the login process. It is unknown as
to whether or not loading has finished when this returns.javax.security.auth.login.LoginException
- If the provided token is invalid.java.lang.IllegalArgumentException
- If the provided token is empty or null.