2022-01-13 00:56:24 +05:00
|
|
|
|
const Command = require("../../base/Command"),
|
2022-01-04 02:18:28 +05:00
|
|
|
|
Discord = require("discord.js"),
|
|
|
|
|
lyricsParse = require("lyrics-finder");
|
|
|
|
|
|
|
|
|
|
class Lyrics extends Command {
|
|
|
|
|
constructor(client) {
|
|
|
|
|
super(client, {
|
|
|
|
|
name: "lyrics",
|
|
|
|
|
dirname: __dirname,
|
|
|
|
|
enabled: true,
|
|
|
|
|
guildOnly: false,
|
|
|
|
|
aliases: ["ly"],
|
|
|
|
|
memberPermissions: [],
|
|
|
|
|
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
|
|
|
|
|
nsfw: false,
|
|
|
|
|
ownerOnly: false,
|
|
|
|
|
cooldown: 3000
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async run(message, args, data) {
|
|
|
|
|
const [songName, artistName] = args.join(" ").split("|");
|
|
|
|
|
if (!songName) return message.error("music/lyrics:MISSING_SONG_NAME");
|
|
|
|
|
|
|
|
|
|
const embed = new Discord.MessageEmbed()
|
|
|
|
|
.setAuthor(message.translate("music/lyrics:LYRICS_OF", {
|
|
|
|
|
songName
|
|
|
|
|
}))
|
|
|
|
|
.setColor(data.config.embed.color)
|
2022-01-05 00:24:57 +05:00
|
|
|
|
.setFooter({
|
|
|
|
|
text: data.config.embed.footer
|
|
|
|
|
});
|
2022-01-04 02:18:28 +05:00
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const songNameFormated = songName
|
|
|
|
|
.toLowerCase()
|
|
|
|
|
.replace(/\(lyrics|lyric|official music video|audio|official|official video|official video hd|clip officiel|clip|extended|hq\)/g, "")
|
|
|
|
|
.split(" ").join("%20");
|
|
|
|
|
|
|
|
|
|
let lyrics = await lyricsParse(songNameFormated, artistName) || "Не найдено!";
|
|
|
|
|
|
|
|
|
|
if (lyrics.length > 2040) {
|
|
|
|
|
lyrics = lyrics.substr(0, 2000) + message.translate("music/lyrics:AND_MORE") + "\n[" + message.translate("music/lyrics:CLICK_HERE") + "]" + `(https://www.musixmatch.com/search/${songName.replace(" ", "+")})`;
|
|
|
|
|
} else if (!lyrics.length) {
|
|
|
|
|
return message.error("music/lyrics:NO_LYRICS_FOUND", {
|
|
|
|
|
songName
|
|
|
|
|
});
|
2022-01-13 00:26:23 +05:00
|
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
|
|
|
|
|
|
embed.setDescription(lyrics);
|
2022-02-13 17:26:12 +05:00
|
|
|
|
message.reply({
|
2022-01-05 00:24:57 +05:00
|
|
|
|
embeds: [embed]
|
|
|
|
|
});
|
2022-01-04 02:18:28 +05:00
|
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log(e);
|
|
|
|
|
message.error("music/lyrics:NO_LYRICS_FOUND", {
|
|
|
|
|
songName
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-13 00:26:23 +05:00
|
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
|
|
|
|
|
|
module.exports = Lyrics;
|