2022-10-26 12:38:28 +02:00
|
|
|
|
const { EmbedBuilder } = require("discord.js");
|
2021-11-18 18:56:42 +01:00
|
|
|
|
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()
|
2021-11-18 18:56:42 +01:00
|
|
|
|
.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}` })
|
2021-11-18 18:56:42 +01:00
|
|
|
|
.setThumbnail(lyricsdata.image)
|
|
|
|
|
.setTimestamp();
|
|
|
|
|
const lyricsMsg = await interaction.followUp({ embeds: [lyricsEmbed] });
|
|
|
|
|
if (splittedLyrics.length > 1) {
|
|
|
|
|
await splitlyrics.pagination(
|
|
|
|
|
lyricsMsg,
|
|
|
|
|
interaction.user,
|
|
|
|
|
splittedLyrics
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|