Lavalink-Client
  • 😁Lavalink Client
  • Basics
    • How it works
    • Get Started
    • Example Discord Bot
  • Documentation
    • LavalinkManager
      • Manager Options
        • ManagerQueueOptions
          • QueueStoreManager
          • QueueChangesWatcher
        • ManagerPlayerOptions
          • RequestTransformer
          • AutoplayFunction
        • BotClientOptions
      • ManagerUtils
    • NodeManager
      • Types
        • LavalinkNode
        • LavalinkNodeOptions
    • Player
      • PlayerOptions
      • PlayerDestroyReasons
      • PlayerTypes
        • RepeatMode
        • PlayerJson
    • Other Types
      • EQBand
      • FilterData
        • KaraokeFilter
      • Track
        • TrackInfo
        • PluginInfo
      • UnresolvedTrack
      • UnresolvedQuery
      • LavalinkTrack
        • Base64
        • LavalinkTrackInfo
      • Payloads
        • GuildShardPayload
        • PlayerEvent
        • TrackStartEvent
        • TrackEndEvent
        • TrackStuckEvent
        • TrackExceptionEvent
        • WebSocketClosedEvent
      • SearchPlatform
        • LavalinkSearchPlatform
        • ClientSearchPlatform
      • SourceNames
        • LavalinkSourceNames
        • LavaSrc SourceNames (lavalink-plugin)
    • Other Utils and Classes
      • DefaultQueueStore
      • MiniMap
  • Requirements
  • Host a Lavalink-Server
    • application.yml Configuration
      • With Spotify, Deezer, Apple Music, etc.
    • Host via pm2
    • Host via systemd
    • Host via screen
  • ⚪Github
  • 📖Lavalink-Support Server
Powered by GitBook
On this page
  • Constructor
  • Import
  • Overview
  • Properties
  • .LavalinkManager
  • Methods
  • .buildTrack(data: LavalinkTrack|Track, requester:any)
  • .buildUnresolvedTrack(data:UnresolvedQuery|UnresolvedTrack, requester:any)
  • .isNode(data:LavalinkNode)
  • .isNodeOptions(data:LavalinkNodeOptions)
  • .isTrack(data:Track)
  • .isUnresolvedTrack(data:UnresolvedTrack)
  • .isUnresolvedTrackQuery(data:UnresolvedQuery)
  • .getClosestTrack(data:UnresolvedTrack, player: Player)
  • .validateQueryString(node: LavalinkNode, data:string)
  • .validateSourceString(node: LavalinkNode, data:SearchPlatform)
  1. Documentation
  2. LavalinkManager

ManagerUtils

Utils you can use on the Manager side, for Tracks and other things!

PreviousBotClientOptionsNextNodeManager

Last updated 1 year ago

ype:

Constructor

new LavalinkManager(options:ManagerOptions)

Import

index.ts
import { ManagerUtils } from "lavalink-client";
index.js
const { ManagerUtils } = require("lavalink-client");

Overview

Properties
Methods
Event-Listeners


Properties

.LavalinkManager

The provided Manager

Methods

Builds a Lavalink Track Response to a Client-Track.

If no Manager was proivided to the Util Manager, then manager#playerOptions#requestTransformer can't be used.

const LavalinkTrack = await player.node.request("/loadtracks?identifier=dQw4w9WgXcQ");
const ClientTrack = client.lavalink.utils.buildTrack(LavalinkTrack, interaction.user);

Builds an unresolved Track of a UnresolvedQuery / Track.

If no Manager was proivided to the Util Manager, then manager#playerOptions#requestTransformer can't be used.

const UnresolvedTrackQuery = { 
  // you can also do { info: { title, author } }
  title: "Never gonna give you up", 
  author: "Rick Astley"
}
const UnresolvedTrack = client.lavalink.utils.buildUnresolvedTrack(UnresolvedTrackQuery, interaction.user);

Checks if provided data is a Lavalink Node.

if(!client.lavalink.utils.isNode(player?.node))
 throw new Error("player.node is not a valid node")

Checks if provided data is a Lavalink Node Options Object.

if(!client.lavalink.utils.isNodeOptions({
  host: "localhost", port: 999999, // it will say false cause:
  // authorization is missing + port is invalid
}))
 throw new Error("player.node is not a valid node")

Checks if provided data is a Client Track Object.

if(!client.lavalink.utils.isTrack(yourData))
 throw new Error("Provided data is not a Track")

Checks if provided data is a Client UnresolvedTrack Object.

if(!client.lavalink.utils.isUnresolvedTrack(yourData))
 throw new Error("Provided data is not an unresolved Track")

Checks if provided data is a UnresolvedQuery Object.

if(!client.lavalink.utils.isUnresolvedTrackQuery(yourData))
 throw new Error("Provided data is not an unresolved Track Query Object")

Try's to find the Closest Track possible of an unresovled Track

if Unresolved track has encoded: it will try to decode it

If unresolved Track has uri / isrc it will try to search by that

const unresolvedTrack = client.lavalink.utils.buildUnresolved({ title: "Never Gonna Give you up" }, interaction.user);
const closest = await client.lavalink.utils.getClosestTrack(unresolvedTrack, player);
player.queue.add(closest);
// note you can also add unresolved tracks to the queue, the queue will automatically try to resolve it, when it's time to play it.
// you can also run await unresolvedTrack.resolve(); to resolve the track

Checks if the query string contains a link and checks the followings:

  • If its source is enabled on the provided node

  • If managerOptions#validLinks is provided, it also checks for those

if(!client.lavalink.utils.validateQueryString(player.node, "https://www.youtube.com/watch?v=dQw4w9WgXcQ"))
 throw new Error("Can't use that link, cause the source of it is disabled on lavalink")

Checks if SearchPlatform is useable, by checking if the source is enabled on the provided node

if(!client.lavalink.utils.validateSourceString(player.node, "youtube"))
 throw new Error("Can't use that source, cause it's disabled on lavalink")

Type: |

.buildTrack(data: |, requester:any)

Returns:

.buildUnresolvedTrack(data:|, requester:any)

Returns:

.isNode(data:)

Returns:

.isNodeOptions(data:)

Returns:

.isTrack(data:)

Returns:

.isUnresolvedTrack(data:)

Returns:

.isUnresolvedTrackQuery(data:)

Returns:

.getClosestTrack(data:, player: )

Returns: <| >

.validateQueryString(node: , data:)

Returns:

.validateSourceString(node: , data:)

Returns:

class
LavalinkManager
null
LavalinkTrack
Track
Track
UnresolvedQuery
UnresolvedTrack
UnresolvedTrack
LavalinkNode
boolean
LavalinkNodeOptions
boolean
Track
boolean
UnresolvedTrack
boolean
UnresolvedQuery
boolean
UnresolvedTrack
Player
Promise
Track
undefined
LavalinkNode
string
boolean
LavalinkNode
SearchPlatform
boolean
LavalinkManager
buildTrack
buildUnresolvedTrack
isNode
isNodeOptions
isTrack
isUnresolvedTrack
isUnresolvedTrackQuery
getClosestTrack
validateQueryString
validateSourceString