JavaLyricsPlugin
API reference for the JavaLyricsPlugin in Moonlink.js
JavaLyricsPlugin Class
The JavaLyricsPlugin
integrates with the Java Lyrics Lavalink plugin to provide advanced 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.
This plugin requires a Lavalink server running the Java Lyrics
plugin.
Properties
Property | Type | Description |
---|---|---|
name | string | The name of the plugin: java-lyrics-plugin . |
capabilities | string[] | Declares java-lyrics capability. |
node | Node | The associated Node instance. |
Methods
load
Load Plugin
Initializes the plugin for a given node.
Parameters
Returns & Example
Returns
• void
// Called internally by PluginManager
::
unload
Unload Plugin
Cleans up plugin resources, including clearing caches and timeouts.
Parameters
Returns & Example
Returns
• void
// Called internally by PluginManager
onTrackEnd
On Track End
Handles cleanup for live lyrics subscriptions when a track ends.
Parameters
Returns & Example
Returns
• void
// Called internally by Node when a track ends
search
Search Lyrics
Searches for lyrics based on a query.
Parameters
Returns & Example
Returns
• Promise<any[]>
— An array of search results.
const results = await plugin.search('Never Gonna Give You Up');
getLyricsByVideoId
Get Lyrics by Video ID
Fetches lyrics for a YouTube video by its ID.
Parameters
Returns & Example
Returns
• Promise<ILavaLyricsObject | null>
— Lyrics data or null
if not found.
const lyrics = await plugin.getLyricsByVideoId('dQw4w9WgXcQ');
getLyricsForCurrentTrack
Get Lyrics for Current Track
Fetches lyrics for the currently playing track of a specific player.
Parameters
Returns & Example
Returns
• Promise<ILavaLyricsObject | null>
— Lyrics data or null
if not found.
const lyrics = await plugin.getLyricsForCurrentTrack('123456789');
getStaticLyricsForTrack
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
Returns & Example
Returns
• Promise<ILavaLyricsObject | null>
— Lyrics data or null
if not found.
const staticLyrics = await plugin.getStaticLyricsForTrack('123456789');
subscribeToLiveLyrics
Subscribe to Live Lyrics
Subscribes to live lyrics updates for a specific guild. The plugin will schedule callbacks based on track position.
Parameters
Returns & Example
Returns
• Promise<void>
// Called internally by Manager.subscribeLyrics
unsubscribeFromLiveLyrics
Unsubscribe from Live Lyrics
Unsubscribes from live lyrics updates for a specific guild.
Parameters
Returns & Example
Returns
• Promise<void>
// Called internally by Manager.unsubscribeLyrics
registerLyricsCallback
Register Lyrics Callback
Registers a callback function to receive live lyrics line updates for a specific guild.
Parameters
Returns & Example
Returns
• void
// Called internally by Manager.subscribeLyrics
unregisterLyricsCallback
Unregister Lyrics Callback
Unregisters the lyrics callback function for a specific guild.
Parameters
Returns & Example
Returns
• void
// Called internally by Manager.unsubscribeLyrics
handleEvent
Handle Event
Handles incoming events from the Lavalink node related to lyrics. This method is called internally by the Node.
Parameters
Returns & Example
Returns
• void
// Called internally by Node