Class LavalinkClient
-
- All Implemented Interfaces:
-
java.io.Closeable,java.lang.AutoCloseable,reactor.core.Disposable
public final class LavalinkClient implements Closeable, Disposable
-
-
Field Summary
Fields Modifier and Type Field Description private final List<LavalinkNode>nodesprivate final List<Link>linksprivate final Flux<ClientEvent>fluxprivate ILoadBalancerloadBalancerprivate final LonguserId
-
Constructor Summary
Constructors Constructor Description LavalinkClient(Long userId)
-
Method Summary
Modifier and Type Method Description final List<LavalinkNode>getNodes()final List<Link>getLinks()final Flux<ClientEvent>getFlux()final ILoadBalancergetLoadBalancer()To determine the best node, we use a load balancer. final UnitsetLoadBalancer(ILoadBalancer loadBalancer)To determine the best node, we use a load balancer. final LonggetUserId()final LavalinkNodeaddNode(NodeOptions nodeOptions)Add a node to the client. final BooleanremoveNode(String name)Remove a node by its name. final BooleanremoveNode(LavalinkNode node)Disconnect and remove a node the client. final LinkgetOrCreateLink(Long guildId, VoiceRegion region)Get or crate a link between a guild and a node. final LinkgetOrCreateLink(Long guildId)Get or crate a link between a guild and a node. final LinkgetLinkIfCached(Long guildId)Returns a Link if it exists in the cache. final <T extends ClientEvent> Flux<T>on(Class<T> type)Listen to events from all nodes. final <T extends ClientEvent> Flux<T>on()Listen to events from all nodes. Unitclose()Close the client and disconnect all nodes. Unitdispose()-
-
Constructor Detail
-
LavalinkClient
LavalinkClient(Long userId)
- Parameters:
userId- ID of the bot for authenticating with Discord
-
-
Method Detail
-
getNodes
final List<LavalinkNode> getNodes()
-
getFlux
final Flux<ClientEvent> getFlux()
-
getLoadBalancer
final ILoadBalancer getLoadBalancer()
To determine the best node, we use a load balancer. It is recommended to not change the load balancer after you've connected to a voice channel.
-
setLoadBalancer
final Unit setLoadBalancer(ILoadBalancer loadBalancer)
To determine the best node, we use a load balancer. It is recommended to not change the load balancer after you've connected to a voice channel.
-
addNode
final LavalinkNode addNode(NodeOptions nodeOptions)
Add a node to the client.
- Parameters:
nodeOptions- a populated NodeOptionsObject
-
removeNode
final Boolean removeNode(String name)
Remove a node by its name.
-
removeNode
final Boolean removeNode(LavalinkNode node)
Disconnect and remove a node the client.
-
getOrCreateLink
@JvmOverloads() final Link getOrCreateLink(Long guildId, VoiceRegion region)
Get or crate a link between a guild and a node.
- Parameters:
guildId- The id of the guildregion- (not currently used) The target voice region of when to select a node
-
getOrCreateLink
@JvmOverloads() final Link getOrCreateLink(Long guildId)
Get or crate a link between a guild and a node.
- Parameters:
guildId- The id of the guild
-
getLinkIfCached
final Link getLinkIfCached(Long guildId)
Returns a Link if it exists in the cache. If we select a link for voice updates, we don't know the region yet.
-
on
final <T extends ClientEvent> Flux<T> on(Class<T> type)
Listen to events from all nodes. Please note that uncaught exceptions will cause the listener to stop emitting events.
- Parameters:
type- the ClientEvent to listen for- Returns:
a Flux of ClientEvents
-
on
final <T extends ClientEvent> Flux<T> on()
Listen to events from all nodes. Please note that uncaught exceptions will cause the listener to stop emitting events.
- Returns:
a Flux of ClientEvents
-
-
-
-