Interface DiscordApiBuilderDelegate



  • public interface DiscordApiBuilderDelegate
    This class is internally used by the DiscordApiBuilder to create discord api instances. You usually don't want to interact with this object.
    • Method Detail

      • setProxySelector

        void setProxySelector​(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​(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​(String token)
        Sets the token.
        Parameters:
        token - The token to set.
      • getToken

        Optional<String> getToken​()
        Gets the token.
        Returns:
        The token.
      • setAccountType

        void setAccountType​(AccountType accountType)
        Sets the account type.
        Parameters:
        accountType - The account type to set.
      • getAccountType

        AccountType getAccountType​()
        Gets the account type.
        Returns:
        The account type.
      • getTotalShards

        int getTotalShards​()
        Gets the total shards.
        Returns:
        The total shards.
      • getCurrentShard

        int getCurrentShard​()
        Sets 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.
      • loginShards

        Collection<CompletableFuture<DiscordApi>> loginShards​(int... shards)
        Login given shards to the account with the given token. It is invalid to call setCurrentShard(int) with anything but 0 before calling this method.
        Parameters:
        shards - The shards to connect, starting with 0!
        Returns:
        A collection of CompletableFutures which contain the DiscordApis for the shards.
      • setRecommendedTotalShards

        CompletableFuture<Void> setRecommendedTotalShards​()
        Sets the recommended total shards.
        Returns:
        A future to check if the action was successful.
      • addListener

        <T extends GloballyAttachableListener> void addListener​(Class<T> listenerClass,
                                                                T listener)
        Adds a GloballyAttachableListener to all created DiscordApi instances. 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 more GloballyAttachableListeners to all created DiscordApi instances. 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​(Class<T> listenerClass,
                                                                Supplier<T> listenerSupplier)
        Adds a GloballyAttachableListener to all created DiscordApi instances. The supplier is called for every created DiscordApi instance, so either the same or different instances can be registered. One example would be a method reference to a default constructor like MyListener::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​(Supplier<GloballyAttachableListener> listenerSupplier)
        Adds a listener that implements one or more GloballyAttachableListeners to all created DiscordApi instances. The supplier is called for every created DiscordApi instance, so either the same or different instances can be registered. One example would be a method reference to a default constructor like MyListener::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​(Class<T> listenerClass,
                                                                Function<DiscordApi,T> listenerFunction)
        Adds a GloballyAttachableListener to all created DiscordApi instances. The function is called for every created DiscordApi instance, so either the same or different instances can be registered. One example would be a method reference to a constructor with a DiscordApi parameter like MyListener::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​(Function<DiscordApi,GloballyAttachableListener> listenerFunction)
        Adds a listener that implements one or more GloballyAttachableListeners to all created DiscordApi instances. The function is called for every created DiscordApi instance, so either the same or different instances can be registered. One example would be a method reference to a constructor with a DiscordApi parameter like MyListener::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 more GloballyAttachableListeners from the list of listeners to be added to DiscordApi instances. If the listener was already added to a DiscordApi instance, 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​(Class<T> listenerClass,
                                                                   T listener)
        Removes a GloballyAttachableListener from the list of listeners to be added to DiscordApi instances. If the listener was already added to a DiscordApi instance, 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​(Supplier<GloballyAttachableListener> listenerSupplier)
        Removes a supplier of listeners that implements one or more GloballyAttachableListeners from the list of listeners to be added to DiscordApi instances. If the listener was already added to a DiscordApi instance, 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​(Class<T> listenerClass,
                                                                           Supplier<T> listenerSupplier)
        Removes a supplier of GloballyAttachableListeners from the list of listeners to be added to DiscordApi instances. If the listener was already added to a DiscordApi instance, 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​(Function<DiscordApi,GloballyAttachableListener> listenerFunction)
        Removes a function that provides listeners that implements one or more GloballyAttachableListeners from the list of listeners to be added to DiscordApi instances. If the listener was already added to a DiscordApi instance, 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​(Class<T> listenerClass,
                                                                           Function<DiscordApi,T> listenerFunction)
        Removes a function that provides GloballyAttachableListeners from the list of listeners to be added to DiscordApi instances. If the listener was already added to a DiscordApi instance, 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.