nyx/unused/commands/Utilities/lyrics.js

59 lines
1.7 KiB
JavaScript
Raw Normal View History

2022-10-26 12:38:28 +02:00
const { EmbedBuilder } = require("discord.js");
const axios = require("axios");
const { Pagination } = require("cath");
module.exports = {
name: "lyrics",
description: "Get lyrics for the currently playing song",
category: "Music",
usage: "(Song)",
options: [
{
type: 3,
name: "song",
description: "The song to search",
required: true,
},
],
run: async (client, interaction, args) => {
const splitlyrics = new Pagination();
const lyricsdata = await axios
.get(
`${process.env.api}/api/v1/lyrics?name=${encodeURIComponent(args[0])}`
)
.then(res => res.data);
if (!lyricsdata?.lyrics) {
interaction.followUp({
content: `**No lyrics are found for ${args[0]}**`,
});
} else {
const splittedLyrics = splitlyrics.chunk(lyricsdata.lyrics, 1024);
2022-10-26 12:38:28 +02:00
const lyricsEmbed = new EmbedBuilder()
.setAuthor(`Lyrics`)
.setColor("YELLOW")
.addFields(
{ name: "Song Name", value: lyricsdata.title, inline: true },
{ name: "", value: "", inline: true },
{
name: "Full Lyrics",
value: `${
process.env.api
}/api/v1/lyrics/full?name=${encodeURIComponent(args[0])}`,
inline: true,
}
)
.setDescription(splittedLyrics[0])
2022-10-26 12:38:28 +02:00
.setFooter({ text: `Page 1 of ${splittedLyrics.length}` })
.setThumbnail(lyricsdata.image)
.setTimestamp();
const lyricsMsg = await interaction.followUp({ embeds: [lyricsEmbed] });
if (splittedLyrics.length > 1) {
await splitlyrics.pagination(
lyricsMsg,
interaction.user,
splittedLyrics
);
}
}
},
};