Star ✨ on GitHub

LyricsKtPlugin

API reference for the LyricsKtPlugin in Moonlink.js

LyricsKtPlugin Class

The LyricsKtPlugin integrates with the Lyrics.kt Lavalink plugin to provide lyrics fetching and live lyrics subscription capabilities. It supports searching for lyrics by query or video ID, and fetching lyrics for the currently playing track.

Properties

PropertyTypeDescription
namestringThe name of the plugin: lyrics.
capabilitiesstring[]Declares lyrics capability.
nodeNodeThe associated Node instance.

Methods

load

loadmethod

Load Plugin

Initializes the plugin for a given node.

Parameters
noderequiredNode
The node instance.

Returns & Example

Returnsvoid

// Called internally by PluginManager

::

unload

unloadmethod

Unload Plugin

Cleans up plugin resources, including clearing caches and timeouts.

Parameters
noderequiredNode
The node instance.

Returns & Example

Returnsvoid

// Called internally by PluginManager

onTrackEnd

onTrackEndmethod

On Track End

Handles cleanup for live lyrics subscriptions when a track ends.

Parameters
playerrequiredPlayer
The player instance.

Returns & Example

Returnsvoid

// Called internally by Node when a track ends

searchmethod

Search Lyrics

Searches for lyrics based on a query.

Parameters
queryrequiredstring
The search query.

Returns & Example

ReturnsPromise<any[]> — An array of search results.

const results = await plugin.search('Never Gonna Give You Up');

getLyricsByVideoId

getLyricsByVideoIdmethod

Get Lyrics by Video ID

Fetches lyrics for a YouTube video by its ID.

Parameters
videoIdrequiredstring
The YouTube video ID.

Returns & Example

ReturnsPromise<ILavaLyricsObject | null> — Lyrics data or null if not found.

const lyrics = await plugin.getLyricsByVideoId('dQw4w9WgXcQ');

getLyricsForCurrentTrack

getLyricsForCurrentTrackmethod

Get Lyrics for Current Track

Fetches lyrics for the currently playing track of a specific player.

Parameters
guildIdrequiredstring
The ID of the guild.

Returns & Example

ReturnsPromise<ILavaLyricsObject | null> — Lyrics data or null if not found.

const lyrics = await plugin.getLyricsForCurrentTrack('123456789');

getStaticLyricsForTrack

getStaticLyricsForTrackmethod

Get Static Lyrics for Track

Attempts to find static (un-timed) lyrics for the currently playing track by searching with a cleaned track title.

Parameters
guildIdrequiredstring
The ID of the guild.

Returns & Example

ReturnsPromise<ILavaLyricsObject | null> — Lyrics data or null if not found.

const staticLyrics = await plugin.getStaticLyricsForTrack('123456789');

subscribeToLiveLyrics

subscribeToLiveLyricsmethod

Subscribe to Live Lyrics

Subscribes to live lyrics updates for a specific guild. The plugin will schedule callbacks based on track position.

Parameters
guildIdrequiredstring
The ID of the guild.

Returns & Example

ReturnsPromise<void>

// Called internally by Manager.subscribeLyrics

unsubscribeFromLiveLyrics

unsubscribeFromLiveLyricsmethod

Unsubscribe from Live Lyrics

Unsubscribes from live lyrics updates for a specific guild.

Parameters
guildIdrequiredstring
The ID of the guild.

Returns & Example

ReturnsPromise<void>

// Called internally by Manager.unsubscribeLyrics

registerLyricsCallback

registerLyricsCallbackmethod

Register Lyrics Callback

Registers a callback function to receive live lyrics line updates for a specific guild.

Parameters
guildIdrequiredstring
The ID of the guild.
callbackrequired(line: ILavaLyricsLine) => void
The callback function to invoke with each lyrics line.

Returns & Example

Returnsvoid

// Called internally by Manager.subscribeLyrics

unregisterLyricsCallback

unregisterLyricsCallbackmethod

Unregister Lyrics Callback

Unregisters the lyrics callback function for a specific guild.

Parameters
guildIdrequiredstring
The ID of the guild.

Returns & Example

Returnsvoid

// Called internally by Manager.unsubscribeLyrics

handleEvent

handleEventmethod

Handle Event

Handles incoming events from the Lavalink node related to lyrics. This method is called internally by the Node.

Parameters
noderequiredNode
The node instance.
payloadrequiredany
The event payload from Lavalink.

Returns & Example

Returnsvoid

// Called internally by Node