Discord Player
Common actions

Getting Lyrics

Learn how to add plain or synced lyrics to your bot

Discord Player provides two different methods for getting lyrics of a song. The lyrics client is built into discord-player itself and provides both plaintext and synced lyrics. It is powered by lrclib.

Plain Lyrics

lyrics.js
const lyrics = await player.lyrics.search({
  q: 'alan walker faded',
}); // this is a lot better than genius but sometimes gives weird result, specify artistName as well in such situations
 
if (!lyrics.length) return interaction.followUp({ content: 'No lyrics found', ephemeral: true });
 
const trimmedLyrics = lyrics[0].plainLyrics.substring(0, 1997);
 
const embed = new EmbedBuilder()
  .setTitle(lyrics[0].title)
  .setURL(lyrics[0].url)
  .setThumbnail(lyrics[0].thumbnail)
  .setAuthor({
    name: lyrics[0].artist.name,
    iconURL: lyrics[0].artist.image,
    url: lyrics[0].artist.url,
  })
  .setDescription(trimmedLyrics.length === 1997 ? `${trimmedLyrics}...` : trimmedLyrics)
  .setColor('Yellow');
 
return interaction.followUp({ embeds: [embed] });

Synced Lyrics

synced-lyrics.js
const results = await player.lyrics.search({
  q: 'alan walker faded',
}); // this is a lot better than genius but sometimes gives weird result, specify artistName as well in such situations
 
const first = results[0];
 
if (!first.syncedLyrics) {
  return; // no synced lyrics available
}
 
// load raw lyrics to the queue
const syncedLyrics = queue.syncedLyrics(lyrics);
 
syncedLyrics.at(timestampInMilliseconds); // manually get a line at a specific timestamp
 
// Listen to live updates. This will be called whenever discord-player detects a new line in the lyrics
syncedLyrics.onChange(async (lyrics, timestamp) => {
  // timestamp = timestamp in lyrics (not queue's time)
  // lyrics = line in that timestamp
  console.log(timestamp, lyrics);
  await interaction.channel?.send({
    content: `[${timestamp}]: ${lyrics}`,
  });
});
 
const unsubscribe = syncedLyrics.subscribe(); // start watching the queue for live updates. The onChange will not be called unless subscribe() has been called.
 
unsubscribe(); // stop watching the queue for live updates

Discord Player relies on queue's current time to detect the current line in the lyrics. It does not validate if the current track is the same as the track for which lyrics were fetched.

On this page