nyx/commands/Music/lyrics.js

31 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-07-13 05:17:39 +02:00
const { MessageEmbed } = require("discord.js");
2021-06-12 12:53:51 +02:00
const lyricsFinder = require("lyrics-finder");
2021-06-24 09:53:19 +02:00
const splitlyrics = require("../../util/pagination/pagination");
2021-06-12 12:53:51 +02:00
module.exports = {
name: "lyrics",
description: "Get lyrics for the currently playing song",
category: "Music",
2021-07-13 05:17:39 +02:00
usage: "(Song)",
2021-06-12 12:53:51 +02:00
run: async (client, message, args) => {
let lyrics = null;
try {
2021-07-13 05:17:39 +02:00
lyrics = await lyricsFinder(args.slice(0).join(" "), "");
2021-06-12 12:53:51 +02:00
if (!lyrics)
2021-07-13 05:17:39 +02:00
lyrics = `**No lyrics are found for ${args.slice(0).join(" ")}.**`;
2021-06-12 12:53:51 +02:00
} catch (error) {
2021-07-13 05:17:39 +02:00
lyrics = `**No lyrics are found for ${args.slice(0).join(" ")}.**`;
2021-06-12 12:53:51 +02:00
}
const splittedLyrics = splitlyrics.chunk(lyrics, 1024);
let lyricsEmbed = new MessageEmbed()
2021-07-13 05:17:39 +02:00
.setAuthor(`Lyrics`)
2021-06-12 12:53:51 +02:00
.setColor("YELLOW")
.setDescription(splittedLyrics[0])
.setFooter(`Page 1 of ${splittedLyrics.length}.`)
.setTimestamp();
const lyricsMsg = await message.channel.send(lyricsEmbed);
if (splittedLyrics.length > 1)
await splitlyrics.pagination(lyricsMsg, message.author, splittedLyrics);
},
};