From ed53e6b0435b36f3e24f3a8ab729d84deb58a6ba Mon Sep 17 00:00:00 2001 From: Berus Date: Wed, 7 Sep 2022 16:46:46 +0700 Subject: [PATCH 1/8] Create Lyrics.js --- src/commands/music/Lyrics.js | 74 ++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/commands/music/Lyrics.js diff --git a/src/commands/music/Lyrics.js b/src/commands/music/Lyrics.js new file mode 100644 index 00000000..f5c51d99 --- /dev/null +++ b/src/commands/music/Lyrics.js @@ -0,0 +1,74 @@ +const { + ApplicationCommandOptionType +} = require('discord.js'); +const Command = require('../../structures/Command'); +const lyricsFinder = require("lyrics-finder"); +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: 'Enter song name or current song playing.', + }, ], + slashCommand: true, + }); + } + async run(client, ctx, args) { + const player = client.music.players.get(ctx.guild.id); + let SongTitle = args.join(" "); + if (!args[0] && !player || !player.queue.current) return ctx.sendMessage('❌ | Nothing is playing right now...') + if (!args[0]) SongTitle = player.queue.current.title; + let FindSongTitle = SongTitle.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 lyrics = await lyricsFinder(FindSongTitle); + const pages = []; + if (!lyrics) + return ctx.sendMessage(`**No lyrics found for -** \`${SongTitle}\``); + lyrics = lyrics.split("\n"); //spliting into lines + let SplitedLyrics = _.chunk(lyrics, 40); //45 lines each page + + SplitedLyrics.map((ly) => { + let pagesNum = SplitedLyrics.length; + if (pagesNum === 0) pagesNum = 1; + for (let i = 0; i <= pagesNum; i++) { + let em = new EmbedBuilder() + .setAuthor({ + name: `Lyrics for: ${SongTitle}`, + iconURL: client.user.displayAvatarURL() + }) + .setColor("#292B2F") + .setDescription(ly.join("\n")); + + if (args.join(" ") !== SongTitle) + em.setThumbnail(player.queue.current.thumbnail); + pages.push(em); + + } + }); + + + return ctx.messageHelper.paginate(pages); + + } +}; From a62c1b9a0a90f7b71082e26f5d50ff040b31c96b Mon Sep 17 00:00:00 2001 From: Seif Date: Wed, 7 Sep 2022 07:34:54 -0700 Subject: [PATCH 2/8] Eslint formatting --- src/commands/music/Lyrics.js | 122 +++++++++++++++++------------------ 1 file changed, 59 insertions(+), 63 deletions(-) diff --git a/src/commands/music/Lyrics.js b/src/commands/music/Lyrics.js index f5c51d99..d9511b0d 100644 --- a/src/commands/music/Lyrics.js +++ b/src/commands/music/Lyrics.js @@ -1,74 +1,70 @@ -const { - ApplicationCommandOptionType -} = require('discord.js'); +const { ApplicationCommandOptionType } = require('discord.js'); const Command = require('../../structures/Command'); -const lyricsFinder = require("lyrics-finder"); -const _ = require("lodash"); -const { - EmbedBuilder -} = require('discord.js'); +const lyricsFinder = require('lyrics-finder'); +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: 'Enter song name or current song playing.', - }, ], - slashCommand: true, - }); - } - async run(client, ctx, args) { - const player = client.music.players.get(ctx.guild.id); - let SongTitle = args.join(" "); - if (!args[0] && !player || !player.queue.current) return ctx.sendMessage('❌ | Nothing is playing right now...') - if (!args[0]) SongTitle = player.queue.current.title; - let FindSongTitle = SongTitle.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, - "" - ); + 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: 'Enter song name or current song playing.', + }], + slashCommand: true, + }); + } + async run(client, ctx, args) { + const player = client.music.players.get(ctx.guild.id); + let SongTitle = args.join(' '); + if (!args[0] && !player || !player.queue.current) return ctx.sendMessage('❌ | Nothing is playing right now...'); + if (!args[0]) SongTitle = player.queue.current.title; + const FindSongTitle = SongTitle.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 lyrics = await lyricsFinder(FindSongTitle); - const pages = []; - if (!lyrics) - return ctx.sendMessage(`**No lyrics found for -** \`${SongTitle}\``); - lyrics = lyrics.split("\n"); //spliting into lines - let SplitedLyrics = _.chunk(lyrics, 40); //45 lines each page + let lyrics = await lyricsFinder(FindSongTitle); + const pages = []; + if (!lyrics) + return ctx.sendMessage(`**No lyrics found for -** \`${SongTitle}\``); + lyrics = lyrics.split('\n'); // spliting into lines + const SplitedLyrics = _.chunk(lyrics, 40); // 45 lines each page - SplitedLyrics.map((ly) => { - let pagesNum = SplitedLyrics.length; - if (pagesNum === 0) pagesNum = 1; - for (let i = 0; i <= pagesNum; i++) { - let em = new EmbedBuilder() - .setAuthor({ - name: `Lyrics for: ${SongTitle}`, - iconURL: client.user.displayAvatarURL() - }) - .setColor("#292B2F") - .setDescription(ly.join("\n")); + SplitedLyrics.map((ly) => { + let pagesNum = SplitedLyrics.length; + if (pagesNum === 0) pagesNum = 1; + for (let i = 0; i <= pagesNum; i++) { + const em = new EmbedBuilder() + .setAuthor({ + name: `Lyrics for: ${SongTitle}`, + iconURL: client.user.displayAvatarURL(), + }) + .setColor('#292B2F') + .setDescription(ly.join('\n')); - if (args.join(" ") !== SongTitle) - em.setThumbnail(player.queue.current.thumbnail); - pages.push(em); + if (args.join(' ') !== SongTitle) + em.setThumbnail(player.queue.current.thumbnail); + pages.push(em); - } - }); + } + }); - return ctx.messageHelper.paginate(pages); + return ctx.messageHelper.paginate(pages); - } + } }; From ef4b6e523e5762d68d999f11915c26ffb5f5041b Mon Sep 17 00:00:00 2001 From: Berus Date: Fri, 9 Sep 2022 02:38:19 +0700 Subject: [PATCH 3/8] Update Lyrics.js Fix paginate and replace lyrics-finder with genius-lyrics --- src/commands/music/Lyrics.js | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/commands/music/Lyrics.js b/src/commands/music/Lyrics.js index d9511b0d..6e94df40 100644 --- a/src/commands/music/Lyrics.js +++ b/src/commands/music/Lyrics.js @@ -1,6 +1,7 @@ const { ApplicationCommandOptionType } = require('discord.js'); const Command = require('../../structures/Command'); -const lyricsFinder = require('lyrics-finder'); +const genius = require("genius-lyrics"); +const Genius = new genius.Client(process.env.GENIUS_API); const _ = require('lodash'); const { EmbedBuilder } = require('discord.js'); @@ -30,24 +31,20 @@ module.exports = class Lyrics extends Command { async run(client, ctx, args) { const player = client.music.players.get(ctx.guild.id); let SongTitle = args.join(' '); - if (!args[0] && !player || !player.queue.current) return ctx.sendMessage('❌ | Nothing is playing right now...'); + if (!args[0] && !player) return ctx.sendMessage('❌ | Nothing is playing right now...'); if (!args[0]) SongTitle = player.queue.current.title; const FindSongTitle = SongTitle.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 lyrics = await lyricsFinder(FindSongTitle); - const pages = []; - if (!lyrics) - return ctx.sendMessage(`**No lyrics found for -** \`${SongTitle}\``); - lyrics = lyrics.split('\n'); // spliting into lines + let songs = (await Genius.songs.search(FindSongTitle))[0] + const songs_lyrics = await songs.lyrics() + if (!songs_lyrics) return ctx.sendMessage(`**No lyrics found for -** \`${SongTitle}\``); + lyrics = songs_lyrics.split('\n'); // spliting into lines const SplitedLyrics = _.chunk(lyrics, 40); // 45 lines each page - SplitedLyrics.map((ly) => { - let pagesNum = SplitedLyrics.length; - if (pagesNum === 0) pagesNum = 1; - for (let i = 0; i <= pagesNum; i++) { + let Pages = SplitedLyrics.map((ly) => { const em = new EmbedBuilder() .setAuthor({ name: `Lyrics for: ${SongTitle}`, @@ -58,13 +55,12 @@ module.exports = class Lyrics extends Command { if (args.join(' ') !== SongTitle) em.setThumbnail(player.queue.current.thumbnail); - pages.push(em); - - } + + return em; }); - return ctx.messageHelper.paginate(pages); + return ctx.messageHelper.paginate(Pages); } }; From e146e24fee46dfb7d163fe9ade2010f7ca529055 Mon Sep 17 00:00:00 2001 From: Berus Date: Fri, 9 Sep 2022 14:18:41 +0700 Subject: [PATCH 4/8] Update Lyrics.js when I deleted console.log I deleted the variable assignment --- src/commands/music/Lyrics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/music/Lyrics.js b/src/commands/music/Lyrics.js index 6e94df40..24e2b839 100644 --- a/src/commands/music/Lyrics.js +++ b/src/commands/music/Lyrics.js @@ -41,7 +41,7 @@ module.exports = class Lyrics extends Command { let songs = (await Genius.songs.search(FindSongTitle))[0] const songs_lyrics = await songs.lyrics() if (!songs_lyrics) return ctx.sendMessage(`**No lyrics found for -** \`${SongTitle}\``); - lyrics = songs_lyrics.split('\n'); // spliting into lines + const lyrics = songs_lyrics.split('\n'); // spliting into lines const SplitedLyrics = _.chunk(lyrics, 40); // 45 lines each page let Pages = SplitedLyrics.map((ly) => { From b7a35b2fde7b96c3320a0bb19364c362ba1b44df Mon Sep 17 00:00:00 2001 From: Seif Date: Fri, 9 Sep 2022 10:49:18 -0700 Subject: [PATCH 5/8] Remove util music folder --- src/index.js | 2 +- src/utils/{music => }/formatDuration.js | 0 src/utils/{music => }/missingPermissions.js | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename src/utils/{music => }/formatDuration.js (100%) rename src/utils/{music => }/missingPermissions.js (100%) 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 From 374762b799982ad9ea457c6367fdb97df97d2eeb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Oct 2022 03:03:12 +0000 Subject: [PATCH 6/8] Bump blapi from 2.2.4 to 3.0.0 Bumps [blapi](https://github.com/botblock/BLAPI) from 2.2.4 to 3.0.0. - [Release notes](https://github.com/botblock/BLAPI/releases) - [Commits](https://github.com/botblock/BLAPI/compare/2.2.4...3.0.0) --- updated-dependencies: - dependency-name: blapi dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ba9497b0..527f6280 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "axios": "^0.27.2", "@discordjs/rest": "^1.1.0", "@sentry/node": "^7.12.1", - "blapi": "^2.2.1", + "blapi": "^3.0.0", "cors": "^2.8.5", "cpu-stat": "^2.0.1", "discord-api-types": "^0.37.6", From 5037c8a58f3fd01399e8da3ca6a3a407e4e08ef7 Mon Sep 17 00:00:00 2001 From: Seif Date: Sat, 12 Nov 2022 11:36:15 -0800 Subject: [PATCH 7/8] eslint fixes --- package.json | 5 ++-- src/commands/music/Lyrics.js | 44 +++++++++++++++--------------------- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index 5550a934..1e5bc950 100644 --- a/package.json +++ b/package.json @@ -27,9 +27,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": "^2.2.1", "cors": "^2.8.5", "cpu-stat": "^2.0.1", @@ -40,6 +40,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", @@ -50,4 +51,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 index 24e2b839..9e41f433 100644 --- a/src/commands/music/Lyrics.js +++ b/src/commands/music/Lyrics.js @@ -23,44 +23,36 @@ module.exports = class Lyrics extends Command { name: 'song', type: ApplicationCommandOptionType.String, required: false, - description: 'Enter song name or current song playing.', + description: 'Song name to find lyrics for.', }], slashCommand: true, }); } async run(client, ctx, args) { const player = client.music.players.get(ctx.guild.id); - let SongTitle = args.join(' '); - if (!args[0] && !player) return ctx.sendMessage('❌ | Nothing is playing right now...'); - if (!args[0]) SongTitle = player.queue.current.title; - const FindSongTitle = SongTitle.replace( + 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(FindSongTitle))[0] - const songs_lyrics = await songs.lyrics() - if (!songs_lyrics) return ctx.sendMessage(`**No lyrics found for -** \`${SongTitle}\``); - const lyrics = songs_lyrics.split('\n'); // spliting into lines - const SplitedLyrics = _.chunk(lyrics, 40); // 45 lines each page + 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 = SplitedLyrics.map((ly) => { - const em = new EmbedBuilder() - .setAuthor({ - name: `Lyrics for: ${SongTitle}`, - iconURL: client.user.displayAvatarURL(), - }) - .setColor('#292B2F') - .setDescription(ly.join('\n')); - - if (args.join(' ') !== SongTitle) - em.setThumbnail(player.queue.current.thumbnail); - - return em; + 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); - + return ctx.messageHelper.paginate(pages); } }; From 1593faf41b7d5d8b6397a9b38d3b71caca2d80e6 Mon Sep 17 00:00:00 2001 From: Seif Date: Sat, 12 Nov 2022 11:37:35 -0800 Subject: [PATCH 8/8] Add to contributors list --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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)