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")