diff --git a/README.md b/README.md index 45873234..077457da 100644 --- a/README.md +++ b/README.md @@ -75,13 +75,14 @@ If you installed and setup eveything correctly then the bot should output someth ## Contributors -- [2D](https://github.com/MeLike2D): Provided modified lavalink version with filters. -- [MrAugu](https://github.com/MrAugu): Cleaned up spaghetti code. -- [Sxmurai](https://github.com/Sxmurai/): Cleaned up spaghetti code. +- [2D](https://github.com/MeLike2D): Provided modified lavalink version with filters +- [MrAugu](https://github.com/MrAugu): Cleaned up spaghetti code +- [Sxmurai](https://github.com/Sxmurai/): Cleaned up spaghetti code - [Omar](https://github.com/HysMX): Fixed Youtube playlist bug -- [lmpham1](https://github.com/lmpham1): Added clean command. +- [lmpham1](https://github.com/lmpham1): Added clean command - [rajamoulimallareddy](https://github.com/rajamoulimallareddy): Updated bot to discord.js v13 - [ilikdoge](https://github.com/ilikdoge): Helped with implementation of yasha and overall development of bot +- [Berus](https://github.com/berusvn): Added lyrics command ## Bot Lists [![Bots On Discord](https://bots.ondiscord.xyz/bots/472714545723342848/embed?theme=dark&showGuilds=true)](https://bots.ondiscord.xyz/bots/472714545723342848) diff --git a/package.json b/package.json index 304fc374..700d0725 100644 --- a/package.json +++ b/package.json @@ -28,9 +28,9 @@ }, "homepage": "https://github.com/Tetracyl/EarTensifier#readme", "dependencies": { - "axios": "^0.27.2", "@discordjs/rest": "^1.1.0", "@sentry/node": "^7.12.1", + "axios": "^0.27.2", "blapi": "^3.0.0", "cors": "^2.8.5", "cpu-stat": "^2.0.1", @@ -41,6 +41,7 @@ "express": "^4.17.1", "figlet": "^1.5.2", "fs": "^0.0.1-security", + "genius-lyrics": "^4.4.0", "humanize-duration": "^3.27.0", "mongoose": "^6.0.12", "signale": "^1.4.0", @@ -51,4 +52,4 @@ "devDependencies": { "eslint": "^8.1.0" } -} \ No newline at end of file +} diff --git a/src/commands/music/Lyrics.js b/src/commands/music/Lyrics.js new file mode 100644 index 00000000..9e41f433 --- /dev/null +++ b/src/commands/music/Lyrics.js @@ -0,0 +1,58 @@ +const { ApplicationCommandOptionType } = require('discord.js'); +const Command = require('../../structures/Command'); +const genius = require("genius-lyrics"); +const Genius = new genius.Client(process.env.GENIUS_API); +const _ = require('lodash'); +const { EmbedBuilder } = require('discord.js'); + +module.exports = class Lyrics extends Command { + constructor(client) { + super(client, { + name: 'lyrics', + description: { + content: 'Search lyrics of the song.', + usage: '', + }, + args: false, + voiceRequirements: { + isInVoiceChannel: false, + isInSameVoiceChannel: false, + isPlaying: false, + }, + options: [{ + name: 'song', + type: ApplicationCommandOptionType.String, + required: false, + description: 'Song name to find lyrics for.', + }], + slashCommand: true, + }); + } + async run(client, ctx, args) { + const player = client.music.players.get(ctx.guild.id); + if (!args[0] && !player) return ctx.sendEphemeralMessage('There is nothing currently playing.'); + let query = args.join(' '); + if (!args[0]) query = player.queue.current.title; + const getSongTitle = query.replace( + /lyrics|lyric|lyrical|official music video|\(official music video\)|\(Official Video\)|audio|\(audio\)|official|official video|official video hd|official hd video|offical video music|\(offical video music\)|extended|hd|(\[.+\])/gi, + '', + ); + + let songs = (await Genius.songs.search(getSongTitle))[0]; + const songTitle = songs.title || song.featuredTitle; + const songLyrics = await songs.lyrics(); + if (!songLyrics) return ctx.sendEphemeralMessage(`**No lyrics found for **${songTitle}**`); + const lyrics = songLyrics.split('\n'); + const formattedLyrics = _.chunk(lyrics, 40); + + let pages = formattedLyrics.map((ly) => { + const embed = new EmbedBuilder() + .setAuthor({ name: `Lyrics for ${songTitle}`, iconURL: client.user.displayAvatarURL() }) + .setDescription(ly.join('\n')) + .setThumbnail(songs.thumbnail); + return embed; + }); + + return ctx.messageHelper.paginate(pages); + } +}; diff --git a/src/index.js b/src/index.js index 1117d8ce..e2c58227 100644 --- a/src/index.js +++ b/src/index.js @@ -24,7 +24,7 @@ if (process.platform != 'linux') { darwin: 'macOS', win32: 'Windows', }; - console.error('You must be on linux to run this bot. You are currently using:', alias[process.platform] || process.platform); + logger.error('You must be on linux to run this bot. You are currently using:', alias[process.platform] || process.platform); } if (process.env.NODE_ENV == 'production') { diff --git a/src/utils/music/formatDuration.js b/src/utils/formatDuration.js similarity index 100% rename from src/utils/music/formatDuration.js rename to src/utils/formatDuration.js diff --git a/src/utils/music/missingPermissions.js b/src/utils/missingPermissions.js similarity index 100% rename from src/utils/music/missingPermissions.js rename to src/utils/missingPermissions.js