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.
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.
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.
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
NodeErrorif your fleet is mixed. - Player scope:
subscribe/unsubscribe/currentact on the player's guild;gettakes any track. - Events, not polling: after subscribing, read lines from
LyricsLine;LyricsFoundfires once with the whole result. - Cleanup timing: unsubscribe on
QueueEndandPlayerDestroyso the node stops pushing lines for a player that no longer exists.