Skip to content

Commit

Permalink
Update lyrics.js
Browse files Browse the repository at this point in the history
Increase lyrics to more than 1 embed
  • Loading branch information
Colonel-Ltd authored Mar 20, 2021
1 parent 30ed920 commit 8ad1786
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions commands/lyrics.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
const { MessageEmbed } = require("discord.js");
const lyricsFinder = require("lyrics-finder");
const sendError = require("../util/error");
const splitlyrics = require("../util/pagination");

module.exports = {
info: {
name: "lyrics",
description: "Get lyrics for the currently playing song",
usage: "[lyrics]",
aliases: ["ly"],
},
info: {
name: "lyrics",
description: "Get lyrics for the currently playing song",
usage: "[lyrics]",
aliases: ["ly"],
},

run: async function (client, message, args) {
const queue = message.client.queue.get(message.guild.id);
if (!queue) return sendError("There is nothing playing.",message.channel).catch(console.error);
run: async function (client, message, args) {
const queue = message.client.queue.get(message.guild.id);
if (!queue) return sendError("There is nothing playing.", message.channel).catch(console.error);

let lyrics = null;
let lyrics = null;

try {
lyrics = await lyricsFinder(queue.songs[0].title, "");
if (!lyrics) lyrics = `No lyrics found for ${queue.songs[0].title}.`;
} catch (error) {
lyrics = `No lyrics found for ${queue.songs[0].title}.`;
}
try {
lyrics = await lyricsFinder(queue.songs[0].title, "");
if (!lyrics) lyrics = `No lyrics found for ${queue.songs[0].title}.`;
} catch (error) {
lyrics = `No lyrics found for ${queue.songs[0].title}.`;
}
const splittedLyrics = splitlyrics.chunk(lyrics, 1024);

let lyricsEmbed = new MessageEmbed()
.setAuthor(`${queue.songs[0].title} — Lyrics`, "https://raw.githubusercontent.com/SudhanPlayz/Discord-MusicBot/master/assets/Music.gif")
.setThumbnail(queue.songs[0].img)
.setColor("YELLOW")
.setDescription(lyrics)
.setTimestamp();
let lyricsEmbed = new MessageEmbed()
.setAuthor(`${queue.songs[0].title} — Lyrics`, "https://raw.githubusercontent.com/SudhanPlayz/Discord-MusicBot/master/assets/Music.gif")
.setThumbnail(queue.songs[0].img)
.setColor("YELLOW")
.setDescription(splittedLyrics[0])
.setFooter(`Page 1 of ${splittedLyrics.length}.`)
.setTimestamp();

if (lyricsEmbed.description.length >= 2048)
lyricsEmbed.description = `${lyricsEmbed.description.substr(0, 2045)}...`;
return message.channel.send(lyricsEmbed).catch(console.error);
},
const lyricsMsg = await message.channel.send(lyricsEmbed);
if (splittedLyrics.length > 1) await splitlyrics.pagination(lyricsMsg, message.author, splittedLyrics);
},
};

0 comments on commit 8ad1786

Please sign in to comment.