Documentation LavalinkManager ManagerUtils Utils you can use on the Manager side, for Tracks and other things!
ype: class
Constructor
Copy new LavalinkManager(options:ManagerOptions)
Import
Typescript / ESM JavaScript (cjs)
Copy import { ManagerUtils } from "lavalink-client";
Copy const { ManagerUtils } = require("lavalink-client");
Overview
Properties
Methods
Event-Listeners
Properties
.LavalinkManager
The provided Manager
Type : LavalinkManager | null
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.
Returns : Track
Copy 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.
Returns : UnresolvedTrack
Copy 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.
Returns : boolean
Copy 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.
Returns : boolean
Copy 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.
Returns : boolean
Copy if(!client.lavalink.utils.isTrack(yourData))
throw new Error("Provided data is not a Track")
Checks if provided data is a Client UnresolvedTrack Object.
Returns : boolean
Copy if(!client.lavalink.utils.isUnresolvedTrack(yourData))
throw new Error("Provided data is not an unresolved Track")
Checks if provided data is a UnresolvedQuery Object.
Returns : boolean
Copy 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
Returns : Promise <Track | undefined >
Copy 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
Returns : boolean
Copy 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
Returns : boolean
Copy if(!client.lavalink.utils.validateSourceString(player.node, "youtube"))
throw new Error("Can't use that source, cause it's disabled on lavalink")