Skip to main content
Version: v2.10.0

AutoPlayUtils

Table of Contentsโ€‹

Class Definitionโ€‹

export abstract class AutoPlayUtils {}
info

AutoPlayUtils is an abstract utility class. All members are static โ€” it cannot be instantiated directly.

Methodsโ€‹

buildTracksFromResponse()โ€‹

static buildTracksFromResponse<T>(recommendedResult: LavalinkResponse, requester?: T): Track[]

Converts a raw LavalinkResponse into an array of Track objects, with isAutoplay set to true on each. Handles all load types.

Parametersโ€‹

Parameter Type Description Optional
recommendedResultLavalinkResponseThe raw response from Lavalink.
requesterTThe user to set as the requester on each built track.

Returnsโ€‹

Type Description
Track[]The built tracks with isAutoplay: true.

getRecommendedTracks()โ€‹

static async getRecommendedTracks(track: Track): Promise<Track[]>

Returns recommended tracks for the given track. Uses Last.fm if a lastFmApiKey is configured on the manager; otherwise iterates through autoPlaySearchPlatforms in priority order, querying each enabled source until results are found.

Parametersโ€‹

Parameter Type Description Optional
trackTrackThe currently playing track to base recommendations on.

Returnsโ€‹

Type Description
Promise<Track[]>Recommended tracks, or an empty array if none could be found.

getRecommendedTracksFromLastFm()โ€‹

static async getRecommendedTracksFromLastFm(track: Track, apiKey: string): Promise<Track[]>

Fetches recommended tracks via the Last.fm API using track.getSimilar. Falls back to artist.getTopTracks if no similar tracks are returned.

Parametersโ€‹

Parameter Type Description Optional
trackTrackThe track to find similar tracks for.
apiKeystringThe Last.fm API key.

Returnsโ€‹

Type Description
Promise<Track[]>Recommended tracks, or an empty array if the request fails.

getRecommendedTracksFromSource()โ€‹

static async getRecommendedTracksFromSource(track: Track, platform: AutoPlayPlatform): Promise<Track[]>

Fetches recommended tracks from the specified platform using its native recommendation API (e.g. sprec:, dzrec:, YouTube mix playlists, SoundCloud recommended page). If the track URI does not belong to the target platform, it is first resolved via a search query.

Parametersโ€‹

Parameter Type Description Optional
trackTrackThe track to base recommendations on.
platformAutoPlayPlatformThe platform to fetch recommendations from.

Returnsโ€‹

Type Description
Promise<Track[]>Recommended tracks, or an empty array if the platform is unsupported or the request fails.

init()โ€‹

static async init(manager: Manager): Promise<void>

Initializes the static Manager reference used by AutoPlayUtils. Called internally by the manager.

Parametersโ€‹

Parameter Type Description Optional
managerManagerThe Manager instance.