Class LavalinkNode

  • All Implemented Interfaces:
    java.io.Closeable , java.lang.AutoCloseable , reactor.core.Disposable

    
    public final class LavalinkNode
     implements Disposable, Closeable
                        
    • Method Detail

      • getPlayers

         final Mono<List<LavalinkPlayer>> getPlayers()

        Retrieves a list of all players from the lavalink node.

        Returns:

        A list of all players from the node.

      • getPlayer

         final Mono<LavalinkPlayer> getPlayer(Long guildId)

        Gets the player from the guild id. If the player is not cached, it will be retrieved from the server.

        Parameters:
        guildId - The guild id of the player.
      • createOrUpdatePlayer

         final PlayerUpdateBuilder createOrUpdatePlayer(Long guildId)

        Creates or updates a player.

        Parameters:
        guildId - The guild id that you want to create or update the player for.
        Returns:

        The newly created or updated player.

      • destroyPlayer

         final Mono<Unit> destroyPlayer(Long guildId)

        Destroy a guild's player.

        Parameters:
        guildId - The guild id of the player to destroy.
      • loadItem

         final Mono<LoadResult> loadItem(String identifier)

        Load an item for the player.

        Parameters:
        identifier - The identifier (E.G.
        Returns:

        The LoadResult of whatever you tried to load.

      • decodeTrack

         final Mono<Track> decodeTrack(String encoded)

        Uses the node to decode a base64 encoded track.

        Parameters:
        encoded - The base64 encoded track to decode.
        Returns:

        The decoded track.

      • decodeTracks

         final Mono<Tracks> decodeTracks(List<String> encoded)

        Uses the node to decode a list of base64 encoded tracks.

        Parameters:
        encoded - The base64 encoded tracks to decode.
        Returns:

        The decoded tracks.

      • getNodeInfo

         final Mono<Info> getNodeInfo()

        Get information about the node.

      • customRequest

         final Mono<Response> customRequest(UnaryOperator<HttpBuilder> builderFn)

        Send a custom request to the lavalink node. Any host and port you set will be replaced with the node host automatically. The scheme must match your node's scheme, however.

        It is recommended to use the path setter instead of the url setter when defining a url, like this:

        <pre>{@code customRequest((builder) -> { return builder.path("/some/plugin/path") .get(); }).subscribe(System.out::println); }</pre>
        Parameters:
        builderFn - The request builder function, defaults such as the Authorization header have already been applied
        Returns:

        The Http response from the node, may error with an IllegalStateException when the node is not available.

      • customJsonRequest

         final <T extends Any> Mono<T> customJsonRequest(UnaryOperator<HttpBuilder> builderFn)

        Send a custom request to the lavalink node. Any host and port you set will be replaced with the node host automatically. The scheme must match your node's scheme, however. The response body will be deserialized using the provided deserializer.

        It is recommended to use the path setter instead of the url setter when defining a url, like this:

        <pre>{@code customJsonRequest<SomeType>{ it.path("/some/plugin/path") .get(); }.doOnSuccess { if (it == null) { println("http 204"); } println(it); }.subscribe(); }</pre>
        Parameters:
        builderFn - The request builder function, defaults such as the Authorization header have already been applied
        Returns:

        The Json object from the response body, may error with an IllegalStateException when the node is not available or the response is not successful.

      • customJsonRequest

         final <T extends Any> Mono<T> customJsonRequest(DeserializationStrategy<T> deserializer, UnaryOperator<HttpBuilder> builderFn)

        Send a custom request to the lavalink node. Any host and port you set will be replaced with the node host automatically. The scheme must match your node's scheme, however. The response body will be deserialized using the provided deserializer.

        It is recommended to use the path setter instead of the url setter when defining a url, like this:

        <pre>{@code customJsonRequest(SomeType.Serializer.INSTANCE, (builder) -> { return builder.path("/some/plugin/path") .get(); }).doOnSuccess((result) -> { if (result == null) { println("http 204"); } println(result); }).subscribe(); }</pre>
        Parameters:
        deserializer - The deserializer to use for the response body (E.G.
        builderFn - The request builder function, defaults such as the Authorization header have already been applied
        Returns:

        The Json object from the response body, may error with an IllegalStateException when the node is not available or the response is not successful.