diff --git a/package.json b/package.json index b333de5..65c3d4c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lunox", - "version": "2.2.0", + "version": "2.2.5", "description": "Lunox by @adh319#9370", "main": "sharder.js", "scripts": { @@ -12,10 +12,9 @@ "discord-hybrid-sharding": "^2.1.3", "discord.js": "^14.13.0", "dotenv": "^16.3.1", - "google-search-url": "^0.1.8", "moment": "^2.29.4", "moment-duration-format": "^2.3.2", - "mongoose": "^7.5.4", + "mongoose": "^7.6.0", "node-capitalize": "^1.0.0", "node-cron": "^3.0.2", "node-fetch": "^2.7.0", diff --git a/src/commands/Slash/Music/Lyrics.js b/src/commands/Slash/Music/Lyrics.js index d1dcfdf..0acc2da 100644 --- a/src/commands/Slash/Music/Lyrics.js +++ b/src/commands/Slash/Music/Lyrics.js @@ -31,55 +31,98 @@ module.exports = { const value = interaction.options.getString("search"); - let song = value; + const currentSong = player.currentTrack.info; + const titles = currentSong.title.replace(/\(Official (Video|Audio|Music Video)\)/gi, "").trim(); + const authors = currentSong.author.replace(/- Topic$/gi, "").trim(); - const CurrentSong = player.currentTrack.info; - const titles = CurrentSong.title.replace("(Official Video)", "").replace("(Official Audio)", ""); - const authors = CurrentSong.author.replace("- Topic", ""); + const lyricEmbed = new EmbedBuilder().setColor(client.color); - if (!song && CurrentSong) song = `${titles} ${authors}`; + let lyricSong = null; + let lyricUrl = null; + let lyricThumbnail = null; + let lyricAuthor = null; + let lyricTitle = null; try { - await fetch(`https://some-random-api.com/others/lyrics?title=${song}`) - .then((res) => res.json()) - .then((data) => { - const lyricSong = data.lyrics; - - if (!lyricSong) { - const lyricError = new EmbedBuilder().setColor(client.color).setDescription(`\`❌\` | Lyrics was not found.`); - - return interaction.editReply({ embeds: [lyricError] }); - } - - const lyrics = lyricSong.length > 3905 ? lyricSong.substr(0, 3900) + "....." : lyricSong; - const titleSong = data.title; - const authorSong = data.author; - - const gSearch = { query: `${titleSong} by ${authorSong} lyrics` }; - const gLink = client.gsearch.craft(gSearch).url; - const urlSong = gLink.replace("http", "https"); - - const lyricEmbed = new EmbedBuilder() - .setAuthor({ - name: `${titleSong} by ${authorSong} lyrics`, - iconURL: client.user.displayAvatarURL({ dynamic: true }), - }) - .setColor(client.color) - .setDescription(`${lyrics}\n**[Click Here For More](${urlSong})**`) - .setThumbnail(CurrentSong.image) - .setFooter({ - text: `Requested by ${interaction.user.username}`, - iconURL: interaction.user.displayAvatarURL({ dynamic: true }), - }); - - return interaction.editReply({ embeds: [lyricEmbed] }); - }); + if (value) { + await fetch(`https://weeb-api.vercel.app/genius?query=${value}`) + .then((res) => res.json()) + .then(async (data) => { + const url = data[0].url; + const thumbnail = data[0].image; + const author = data[0].artist; + const title = data[0].title; + + await fetch(`https://weeb-api.vercel.app/lyrics?url=${url}`) + .then((res) => res.json()) + .then((lyrics) => { + lyricSong = lyrics.data; + }); + + lyricUrl = url; + lyricThumbnail = thumbnail; + lyricAuthor = author; + lyricTitle = title; + }); + } else { + await fetch(`https://weeb-api.vercel.app/genius?query=${titles} ${authors}`) + .then((res) => res.json()) + .then(async (data) => { + const url = data[0].url; + const thumbnail = data[0].image; + const author = data[0].artist; + const title = data[0].title; + + await fetch(`https://weeb-api.vercel.app/lyrics?url=${url}`) + .then((res) => res.json()) + .then((lyrics) => { + lyricSong = lyrics.data; + }); + + lyricUrl = url; + lyricThumbnail = thumbnail; + lyricAuthor = author; + lyricTitle = title; + }); + } } catch (err) { - console.log(err); + lyricEmbed.setDescription(`\`❌\` | No lyrics were found!`); + + return interaction.editReply({ embeds: [lyricEmbed], ephemeral: true }); + } + + if (!lyricSong) { + lyricEmbed.setDescription(`\`❌\` | No lyrics were found!`); - const lyricError = new EmbedBuilder().setColor(client.color).setDescription(`\`❌\` | Lyrics was not found.`); + return interaction.editReply({ embeds: [lyricEmbed], ephemeral: true }); + } - return interaction.editReply({ embeds: [lyricError] }); + if (value) { + if (lyricSong.length > 4096) { + lyricEmbed.setDescription(`${lyricSong.slice(0, 3900)}\n\n[Click for more](${lyricUrl})`); + } else { + lyricEmbed.setDescription(`${lyricSong}\n\n[Click for more](${lyricUrl})`); + } + } else { + if (lyricSong.length > 4096) { + lyricEmbed.setDescription(`${lyricSong.slice(0, 3900)}\n\n[Click for more](${lyricUrl})`); + } else { + lyricEmbed.setDescription(`${lyricSong}\n\n[Click for more](${lyricUrl})`); + } } + + lyricEmbed + .setAuthor({ + name: `${lyricTitle} by ${lyricAuthor} Lyrics`, + iconURL: client.user.displayAvatarURL({ size: 2048, dynamic: true }), + }) + .setThumbnail(lyricThumbnail) + .setFooter({ + text: `Requested by ${interaction.user.tag}`, + iconURL: interaction.user.displayAvatarURL({ size: 2048, dynamic: true }), + }) + .setTimestamp(); + + return interaction.editReply({ embeds: [lyricEmbed] }); }, }; diff --git a/src/commands/Slash/Music/NowPlaying.js b/src/commands/Slash/Music/NowPlaying.js index 7f72ed6..741760b 100644 --- a/src/commands/Slash/Music/NowPlaying.js +++ b/src/commands/Slash/Music/NowPlaying.js @@ -60,6 +60,7 @@ module.exports = { else if (player.currentTrack.info.sourceName === "apllemusic") sources = "Apple Music"; else if (player.currentTrack.info.sourceName === "bandcamp") sources = "Bandcamp"; else if (player.currentTrack.info.sourceName === "http") sources = "HTTP"; + else if (player.currentTrack.info.sourceName === "deezer") sources = "Deezer"; const embed = new EmbedBuilder() .setAuthor({ diff --git a/src/lunox.js b/src/lunox.js index 097773e..4f581e0 100644 --- a/src/lunox.js +++ b/src/lunox.js @@ -1,7 +1,6 @@ const { Client, Collection, GatewayIntentBits, Partials } = require("discord.js"); const { Poru } = require("poru"); const { ClusterClient, getInfo } = require("discord-hybrid-sharding"); -const GSearch = require("google-search-url"); class MainClient extends Client { constructor() { @@ -34,7 +33,6 @@ class MainClient extends Client { this.slashCommands = new Collection(); this.premium = new Collection(); this.dev = new Set(); - this.gsearch = GSearch; this.poru = new Poru(this, this.config.nodes, this.config.poruOptions, { send: (guildId, payload) => {