Star ✨ on GitHub

LavaLyricsPlugin

API reference for the LavaLyricsPlugin in Moonlink.js

LavaLyricsPlugin Class

The LavaLyricsPlugin integrates with the LavaLyrics Lavalink plugin to provide lyrics fetching and live lyrics subscription capabilities. It supports fetching lyrics for the current track or a specific encoded track.

Properties

PropertyTypeDescription
namestringThe name of the plugin: lavalyrics-plugin.
capabilitiesstring[]Declares lavalyrics 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.

Parameters
noderequiredNode
The node instance.

Returns & Example

Returnsvoid

// Called internally by PluginManager

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.
skipTrackSourceboolean
Optional: Whether to skip the track's original source when searching for lyrics.

Returns & Example

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

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

getLyricsForTrack

getLyricsForTrackmethod

Get Lyrics for Track

Fetches lyrics for a specific encoded track.

Parameters
encodedTrackrequiredstring
The base64 encoded track string.
skipTrackSourceboolean
Optional: Whether to skip the track's original source when searching for lyrics.

Returns & Example

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

const lyrics = await plugin.getLyricsForTrack('base64EncodedTrack');

subscribeToLiveLyrics

subscribeToLiveLyricsmethod

Subscribe to Live Lyrics

Subscribes to live lyrics updates for a specific guild.

Parameters
guildIdrequiredstring
The ID of the guild.
skipTrackSourceboolean
Optional: Whether to skip the track's original source when searching for lyrics.

Returns & Example

ReturnsPromise<void>

await plugin.subscribeToLiveLyrics('123456789');

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>

await plugin.unsubscribeFromLiveLyrics('123456789');

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

plugin.registerLyricsCallback('123456789', (line) => console.log(line.line));

unregisterLyricsCallback

unregisterLyricsCallbackmethod

Unregister Lyrics Callback

Unregisters the lyrics callback function for a specific guild.

Parameters
guildIdrequiredstring
The ID of the guild.

Returns & Example

Returnsvoid

plugin.unregisterLyricsCallback('123456789');

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