Package org.javacord.api.internal
Interface DiscordApiBuilderDelegate
-
public interface DiscordApiBuilderDelegateThis class is internally used by theDiscordApiBuilderto create discord api instances. You usually don't want to interact with this object.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddIntents(Intent... intents)Adds the given intents to the already set.<T extends GloballyAttachableListener>
voidaddListener(java.lang.Class<T> listenerClass, java.util.function.Function<DiscordApi,T> listenerFunction)Adds aGloballyAttachableListenerto all createdDiscordApiinstances.<T extends GloballyAttachableListener>
voidaddListener(java.lang.Class<T> listenerClass, java.util.function.Supplier<T> listenerSupplier)Adds aGloballyAttachableListenerto all createdDiscordApiinstances.<T extends GloballyAttachableListener>
voidaddListener(java.lang.Class<T> listenerClass, T listener)Adds aGloballyAttachableListenerto all createdDiscordApiinstances.voidaddListener(java.util.function.Function<DiscordApi,GloballyAttachableListener> listenerFunction)Adds a listener that implements one or moreGloballyAttachableListeners to all createdDiscordApiinstances.voidaddListener(java.util.function.Supplier<GloballyAttachableListener> listenerSupplier)Adds a listener that implements one or moreGloballyAttachableListeners to all createdDiscordApiinstances.voidaddListener(GloballyAttachableListener listener)Adds a listener that implements one or moreGloballyAttachableListeners to all createdDiscordApiinstances.intgetCurrentShard()Gets the current shard.java.util.Optional<java.lang.String>getToken()Gets the token.intgetTotalShards()Gets the total shards.booleanisShutdownHookRegistrationEnabled()Checks if newly createdDiscordApiinstances should register a shutdown hook to disconnect the instance.booleanisUserCacheEnabled()Gets whether the user cache is enabled.booleanisWaitingForServersOnStartup()Checks if Javacord should wait for all servers to become available on startup.booleanisWaitingForUsersOnStartup()Checks if Javacord should wait for all users to get cached on startup.java.util.concurrent.CompletableFuture<DiscordApi>login()Logs the bot in.java.util.Collection<java.util.concurrent.CompletableFuture<DiscordApi>>loginShards(int... shards)Login given shards to the account with the given token.<T extends GloballyAttachableListener>
voidremoveListener(java.lang.Class<T> listenerClass, T listener)Removes aGloballyAttachableListenerfrom the list of listeners to be added toDiscordApiinstances.voidremoveListener(GloballyAttachableListener listener)Removes a listener that implements one or moreGloballyAttachableListeners from the list of listeners to be added toDiscordApiinstances.<T extends GloballyAttachableListener>
voidremoveListenerFunction(java.lang.Class<T> listenerClass, java.util.function.Function<DiscordApi,T> listenerFunction)Removes a function that providesGloballyAttachableListeners from the list of listeners to be added toDiscordApiinstances.voidremoveListenerFunction(java.util.function.Function<DiscordApi,GloballyAttachableListener> listenerFunction)Removes a function that provides listeners that implements one or moreGloballyAttachableListeners from the list of listeners to be added toDiscordApiinstances.<T extends GloballyAttachableListener>
voidremoveListenerSupplier(java.lang.Class<T> listenerClass, java.util.function.Supplier<T> listenerSupplier)Removes a supplier ofGloballyAttachableListeners from the list of listeners to be added toDiscordApiinstances.voidremoveListenerSupplier(java.util.function.Supplier<GloballyAttachableListener> listenerSupplier)Removes a supplier of listeners that implements one or moreGloballyAttachableListeners from the list of listeners to be added toDiscordApiinstances.voidsetAllIntentsWhere(java.util.function.Predicate<Intent> condition)Sets the intents where the given predicate matches.voidsetCurrentShard(int currentShard)Sets the current shards.voidsetEventsDispatchable(boolean dispatchEvents)Sets whether this API instance can dispatch events.voidsetGatewayIdentifyRatelimiter(Ratelimiter ratelimiter)Sets a ratelimiter that can be used to respect the 5-second gateway identify ratelimit.voidsetGlobalRatelimiter(Ratelimiter ratelimiter)Sets a ratelimiter that can be used to control global ratelimits.voidsetProxy(java.net.Proxy proxy)Sets the proxy which should be used to connect to the Discord REST API and websocket.voidsetProxyAuthenticator(Authenticator authenticator)Sets the authenticator that should be used to authenticate against proxies that require it.voidsetProxySelector(java.net.ProxySelector proxySelector)Sets the proxy selector which should be used to determine the proxies that should be used to connect to the Discord REST API and websocket.java.util.concurrent.CompletableFuture<java.lang.Void>setRecommendedTotalShards()Sets the recommended total shards.voidsetShutdownHookRegistrationEnabled(boolean registerShutdownHook)Sets if Javacord should register a shutdown hook that disconnects theDiscordApiinstance.voidsetToken(java.lang.String token)Sets the token.voidsetTotalShards(int totalShards)Sets the total shards.voidsetTrustAllCertificates(boolean trustAllCertificates)Sets whether all SSL certificates should be trusted when connecting to the Discord API and websocket.voidsetUserCacheEnabled(boolean enabled)Sets whether the user cache should be enabled.voidsetWaitForServersOnStartup(boolean waitForServersOnStartup)Sets the wait for servers on startup flag.voidsetWaitForUsersOnStartup(boolean waitForUsersOnStartup)Sets the wait for users on startup flag.
-
-
-
Method Detail
-
setGlobalRatelimiter
void setGlobalRatelimiter(Ratelimiter ratelimiter)
Sets a ratelimiter that can be used to control global ratelimits.- Parameters:
ratelimiter- The ratelimiter used to control global ratelimits.
-
setEventsDispatchable
void setEventsDispatchable(boolean dispatchEvents)
Sets whether this API instance can dispatch events.- Parameters:
dispatchEvents- Whether events can be dispatched.
-
setGatewayIdentifyRatelimiter
void setGatewayIdentifyRatelimiter(Ratelimiter ratelimiter)
Sets a ratelimiter that can be used to respect the 5-second gateway identify ratelimit.- Parameters:
ratelimiter- The ratelimiter used to respect the 5-second gateway identify ratelimit.
-
setProxySelector
void setProxySelector(java.net.ProxySelector proxySelector)
Sets the proxy selector which should be used to determine the proxies that should be used to connect to the Discord REST API and websocket.- Parameters:
proxySelector- The proxy selector to set.
-
setProxy
void setProxy(java.net.Proxy proxy)
Sets the proxy which should be used to connect to the Discord REST API and websocket.- Parameters:
proxy- The poxy to set.
-
setProxyAuthenticator
void setProxyAuthenticator(Authenticator authenticator)
Sets the authenticator that should be used to authenticate against proxies that require it.- Parameters:
authenticator- The proxy authenticator to set.
-
setTrustAllCertificates
void setTrustAllCertificates(boolean trustAllCertificates)
Sets whether all SSL certificates should be trusted when connecting to the Discord API and websocket.- Parameters:
trustAllCertificates- Whether to trust all SSL certificates.
-
setToken
void setToken(java.lang.String token)
Sets the token.- Parameters:
token- The token to set.
-
getToken
java.util.Optional<java.lang.String> getToken()
Gets the token.- Returns:
- The token.
-
setTotalShards
void setTotalShards(int totalShards)
Sets the total shards.- Parameters:
totalShards- The total shards to set.- See Also:
DiscordApiBuilder.setTotalShards(int)
-
getTotalShards
int getTotalShards()
Gets the total shards.- Returns:
- The total shards.
-
setCurrentShard
void setCurrentShard(int currentShard)
Sets the current shards.- Parameters:
currentShard- The current shards to set.- See Also:
DiscordApiBuilder.setCurrentShard(int)
-
getCurrentShard
int getCurrentShard()
Gets the current shard.- Returns:
- The current shard.
-
setWaitForServersOnStartup
void setWaitForServersOnStartup(boolean waitForServersOnStartup)
Sets the wait for servers on startup flag.- Parameters:
waitForServersOnStartup- The wait for servers on startup flag to set.
-
isWaitingForServersOnStartup
boolean isWaitingForServersOnStartup()
Checks if Javacord should wait for all servers to become available on startup.- Returns:
- If Javacord should wait.
-
setWaitForUsersOnStartup
void setWaitForUsersOnStartup(boolean waitForUsersOnStartup)
Sets the wait for users on startup flag.- Parameters:
waitForUsersOnStartup- The wait for users on startup flag to set.
-
isWaitingForUsersOnStartup
boolean isWaitingForUsersOnStartup()
Checks if Javacord should wait for all users to get cached on startup.- Returns:
- If Javacord should wait.
-
setShutdownHookRegistrationEnabled
void setShutdownHookRegistrationEnabled(boolean registerShutdownHook)
Sets if Javacord should register a shutdown hook that disconnects theDiscordApiinstance.By default, Javacord registers a shutdown hook using
Runtime.addShutdownHook(Thread)that calls theDiscordApi.disconnect()method. Setting this flag tofalsewill disable this behavior.- Parameters:
registerShutdownHook- Whether the shutdown hook should be registered or not.
-
isShutdownHookRegistrationEnabled
boolean isShutdownHookRegistrationEnabled()
Checks if newly createdDiscordApiinstances should register a shutdown hook to disconnect the instance.- Returns:
- Whether the shutdown hook will be registered or not.
- See Also:
setShutdownHookRegistrationEnabled(boolean)
-
addIntents
void addIntents(Intent... intents)
Adds the given intents to the already set.- Parameters:
intents- The intents to add.
-
setAllIntentsWhere
void setAllIntentsWhere(java.util.function.Predicate<Intent> condition)
Sets the intents where the given predicate matches.- Parameters:
condition- Whether the intent should be added or not.
-
setUserCacheEnabled
void setUserCacheEnabled(boolean enabled)
Sets whether the user cache should be enabled.By default, the user cache is disabled.
- Parameters:
enabled- Whether the user cache should be enabled.
-
isUserCacheEnabled
boolean isUserCacheEnabled()
Gets whether the user cache is enabled.- Returns:
- Whether the user cache is enabled.
-
login
java.util.concurrent.CompletableFuture<DiscordApi> login()
Logs the bot in.- Returns:
- The discord api instance.
-
loginShards
java.util.Collection<java.util.concurrent.CompletableFuture<DiscordApi>> loginShards(int... shards)
Login given shards to the account with the given token. It is invalid to callsetCurrentShard(int)with anything but0before calling this method.- Parameters:
shards- The shards to connect, starting with0!- Returns:
- A collection of
CompletableFutures which contain theDiscordApis for the shards.
-
setRecommendedTotalShards
java.util.concurrent.CompletableFuture<java.lang.Void> setRecommendedTotalShards()
Sets the recommended total shards.- Returns:
- A future to check if the action was successful.
-
addListener
<T extends GloballyAttachableListener> void addListener(java.lang.Class<T> listenerClass, T listener)
Adds aGloballyAttachableListenerto all createdDiscordApiinstances. Adding a listener multiple times will only add it once. The order of invocation is according to first addition.- Type Parameters:
T- The type of the listener.- Parameters:
listenerClass- The listener class.listener- The listener to add.
-
addListener
void addListener(GloballyAttachableListener listener)
Adds a listener that implements one or moreGloballyAttachableListeners to all createdDiscordApiinstances. Adding a listener multiple times will only add it once. The order of invocation is according to first addition.- Parameters:
listener- The listener to add.
-
addListener
<T extends GloballyAttachableListener> void addListener(java.lang.Class<T> listenerClass, java.util.function.Supplier<T> listenerSupplier)
Adds aGloballyAttachableListenerto all createdDiscordApiinstances. The supplier is called for every createdDiscordApiinstance, so either the same or different instances can be registered. One example would be a method reference to a default constructor likeMyListener::new. Adding a listener multiple times will only add it once. The order of invocation is according to first addition.- Type Parameters:
T- The type of the listener.- Parameters:
listenerClass- The listener class.listenerSupplier- The supplier of listeners to add.
-
addListener
void addListener(java.util.function.Supplier<GloballyAttachableListener> listenerSupplier)
Adds a listener that implements one or moreGloballyAttachableListeners to all createdDiscordApiinstances. The supplier is called for every createdDiscordApiinstance, so either the same or different instances can be registered. One example would be a method reference to a default constructor likeMyListener::new. Adding a listener multiple times will only add it once. The order of invocation is according to first addition.- Parameters:
listenerSupplier- The supplier of listeners to add.
-
addListener
<T extends GloballyAttachableListener> void addListener(java.lang.Class<T> listenerClass, java.util.function.Function<DiscordApi,T> listenerFunction)
Adds aGloballyAttachableListenerto all createdDiscordApiinstances. The function is called for every createdDiscordApiinstance, so either the same or different instances can be registered. One example would be a method reference to a constructor with aDiscordApiparameter likeMyListener::new. Adding a listener multiple times will only add it once. The order of invocation is according to first addition.- Type Parameters:
T- The type of the listener.- Parameters:
listenerClass- The listener class.listenerFunction- The function to provide listeners to add.
-
addListener
void addListener(java.util.function.Function<DiscordApi,GloballyAttachableListener> listenerFunction)
Adds a listener that implements one or moreGloballyAttachableListeners to all createdDiscordApiinstances. The function is called for every createdDiscordApiinstance, so either the same or different instances can be registered. One example would be a method reference to a constructor with aDiscordApiparameter likeMyListener::new. Adding a listener multiple times will only add it once. The order of invocation is according to first addition.- Parameters:
listenerFunction- The function to provide listeners to add.
-
removeListener
void removeListener(GloballyAttachableListener listener)
Removes a listener that implements one or moreGloballyAttachableListeners from the list of listeners to be added toDiscordApiinstances. If the listener was already added to aDiscordApiinstance, it will not get removed by calling this method. This method should normally only be used before calling one of the login methods.- Parameters:
listener- The listener to remove.
-
removeListener
<T extends GloballyAttachableListener> void removeListener(java.lang.Class<T> listenerClass, T listener)
Removes aGloballyAttachableListenerfrom the list of listeners to be added toDiscordApiinstances. If the listener was already added to aDiscordApiinstance, it will not get removed by calling this method. This method should normally only be used before calling one of the login methods.- Type Parameters:
T- The type of the listener.- Parameters:
listenerClass- The listener class.listener- The listener to remove.
-
removeListenerSupplier
void removeListenerSupplier(java.util.function.Supplier<GloballyAttachableListener> listenerSupplier)
Removes a supplier of listeners that implements one or moreGloballyAttachableListeners from the list of listeners to be added toDiscordApiinstances. If the listener was already added to aDiscordApiinstance, it will not get removed by calling this method. This method should normally only be used before calling one of the login methods.- Parameters:
listenerSupplier- The supplier of listeners to remove.
-
removeListenerSupplier
<T extends GloballyAttachableListener> void removeListenerSupplier(java.lang.Class<T> listenerClass, java.util.function.Supplier<T> listenerSupplier)
Removes a supplier ofGloballyAttachableListeners from the list of listeners to be added toDiscordApiinstances. If the listener was already added to aDiscordApiinstance, it will not get removed by calling this method. This method should normally only be used before calling one of the login methods.- Type Parameters:
T- The type of the listener.- Parameters:
listenerClass- The listener class.listenerSupplier- The supplier of listeners to remove.
-
removeListenerFunction
void removeListenerFunction(java.util.function.Function<DiscordApi,GloballyAttachableListener> listenerFunction)
Removes a function that provides listeners that implements one or moreGloballyAttachableListeners from the list of listeners to be added toDiscordApiinstances. If the listener was already added to aDiscordApiinstance, it will not get removed by calling this method. This method should normally only be used before calling one of the login methods.- Parameters:
listenerFunction- The function to provide listeners to remove.
-
removeListenerFunction
<T extends GloballyAttachableListener> void removeListenerFunction(java.lang.Class<T> listenerClass, java.util.function.Function<DiscordApi,T> listenerFunction)
Removes a function that providesGloballyAttachableListeners from the list of listeners to be added toDiscordApiinstances. If the listener was already added to aDiscordApiinstance, it will not get removed by calling this method. This method should normally only be used before calling one of the login methods.- Type Parameters:
T- The type of the listener.- Parameters:
listenerClass- The listener class.listenerFunction- The function to provide listeners to remove.
-
-