Guides

Lyrics

Fetch lyrics and subscribe to live line updates.

Lyrics come from a Lavalink plugin, so every call validates that the node provides the capability before hitting the endpoint — a node without lavalyrics-plugin, java-lyrics-plugin or lavasrc-plugin throws a NodeError instead of returning an empty result.

Fetch

player.lyrics is bound to the player's guild and current track.

fetch-lyrics.ts
import type { ,  } from 'hoshimi';

declare const : ;
declare const : ;

const  = await ..();   // for what is playing now
const  = await ..(); // for any track

if () {
  .(., ..);
}

Pass true to skip the track's own source and go straight to the plugin's providers: player.lyrics.current(true).

Live updates

Subscribing makes the node push LyricsLine events as the track plays.

lyrics-subscription.ts
import { ,  } from 'hoshimi';
import type {  } from 'hoshimi';

declare const : ;
declare const : ;

await ..();

.(., (, , ) => {
  .(., ..);
});

.(., () => {
  .(`No lyrics for ${.}`);
});

await ..();

Cleanup

Unsubscribe when playback ends, and drop whatever you stored alongside it.

lyrics-cleanup.ts
import type {  } from 'hoshimi';

declare const : ;

const  = !!(await ..('enabledLyrics'));

if () {
  await ..();
  await ..('enabledLyrics');
}

Key Concepts

  • Plugin required: all four methods validate the node first; catch NodeError if your fleet is mixed.
  • Player scope: subscribe/unsubscribe/current act on the player's guild; get takes any track.
  • Events, not polling: after subscribing, read lines from LyricsLine; LyricsFound fires once with the whole result.
  • Cleanup timing: unsubscribe on QueueEnd and PlayerDestroy so the node stops pushing lines for a player that no longer exists.