JaBa/commands/Music/lyrics.js

64 lines
1.7 KiB
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const Command = require("../../base/Command.js"),
Discord = require("discord.js"),
lyricsParse = require("lyrics-finder");
class Lyrics extends Command {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-10 21:39:54 +05:00
super(client, {
name: "lyrics",
dirname: __dirname,
enabled: true,
guildOnly: false,
aliases: ["ly"],
2021-12-10 21:39:54 +05:00
memberPermissions: [],
2021-12-26 19:29:37 +05:00
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
2021-12-10 21:39:54 +05:00
nsfw: false,
ownerOnly: false,
cooldown: 3000
2021-12-10 21:39:54 +05:00
});
}
2021-12-26 19:29:37 +05:00
async run(message, args, data) {
2021-12-10 21:39:54 +05:00
const [songName, artistName] = args.join(" ").split("|");
2021-12-11 01:11:50 +05:00
if (!songName) return message.error("music/lyrics:MISSING_SONG_NAME");
2021-12-10 21:39:54 +05:00
const embed = new Discord.MessageEmbed()
2021-12-26 19:29:37 +05:00
.setAuthor(message.translate("music/lyrics:LYRICS_OF", {
songName
}))
2021-12-10 21:39:54 +05:00
.setColor(data.config.embed.color)
2022-01-04 00:35:11 +05:00
.setFooter({
text: data.config.embed.footer
});
2021-12-10 21:39:54 +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");
2021-12-11 01:11:50 +05:00
let lyrics = await lyricsParse(songNameFormated, artistName) || "Не найдено!";
2021-12-10 21:39:54 +05:00
2021-12-11 01:11:50 +05:00
if (lyrics.length > 2040) {
2021-12-26 13:22:43 +05:00
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(" ", "+")})`;
2021-12-11 01:11:50 +05:00
} else if (!lyrics.length) {
2021-12-26 19:29:37 +05:00
return message.error("music/lyrics:NO_LYRICS_FOUND", {
songName
});
2021-12-11 01:11:50 +05:00
};
2021-12-10 21:39:54 +05:00
embed.setDescription(lyrics);
2022-01-04 00:35:11 +05:00
message.channel.send({
embeds: [embed]
});
2021-12-10 21:39:54 +05:00
2021-12-26 19:29:37 +05:00
} catch (e) {
2021-12-10 21:39:54 +05:00
console.log(e);
2021-12-26 19:29:37 +05:00
message.error("music/lyrics:NO_LYRICS_FOUND", {
songName
});
2021-12-10 21:39:54 +05:00
}
}
2021-12-11 01:11:50 +05:00
};
2021-12-10 21:39:54 +05:00
module.exports = Lyrics;