From c759ed6e85e10a60f0284f88f86a43c375b6c443 Mon Sep 17 00:00:00 2001 From: AlexInCube Date: Tue, 9 Jul 2024 17:33:18 +0300 Subject: [PATCH] 3.1.1 Fixed lyrics error handling. Add /lyrics command to wiki. Changed publish-docker-image action to ignore wiki folder. --- .dockerignore | 1 + .github/workflows/publish-docker-image.yaml | 3 +++ package.json | 2 +- src/audioplayer/Lyrics.ts | 24 ++++++++++++--------- src/commands/audio/lyrics.command.ts | 1 + wiki/Commands.md | 6 ++++++ 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/.dockerignore b/.dockerignore index 048b239..a46f2d4 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,3 +5,4 @@ node_modules .env* runInDocker.* yt-cookies.json +wiki diff --git a/.github/workflows/publish-docker-image.yaml b/.github/workflows/publish-docker-image.yaml index e9f40ad..16df902 100644 --- a/.github/workflows/publish-docker-image.yaml +++ b/.github/workflows/publish-docker-image.yaml @@ -3,6 +3,9 @@ name: Publish Docker image on: push: branches: ['master'] + paths-ignore: + - '**/wiki/**' + - '/wiki/**' env: IMAGE_TAG: alexincube/aicotest diff --git a/package.json b/package.json index 510680d..42fe07f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aicbot", - "version": "3.1.0", + "version": "3.1.1", "description": "Discord Bot for playing music", "main": "build/main.js", "scripts": { diff --git a/src/audioplayer/Lyrics.ts b/src/audioplayer/Lyrics.ts index b61e0d9..ac276fe 100644 --- a/src/audioplayer/Lyrics.ts +++ b/src/audioplayer/Lyrics.ts @@ -27,14 +27,18 @@ export async function generateLyricsEmbed(songQuery: string) { return generateErrorEmbed(i18next.t('commands:lyrics_embed_lyrics_not_found')); } - const lyrics = await geniusSong.lyrics(); - - const lyricsText = lyrics.slice(0, 4096); - - return new EmbedBuilder() - .setTitle(geniusSong.title) - .setURL(geniusSong.url) - .setDescription(lyricsText) - .setColor(Colors.Yellow) - .setFooter({ text: i18next.t('commands:lyrics_embed_text_not_correct') }); + try{ + const lyrics = await geniusSong.lyrics(); + + const lyricsText = lyrics.slice(0, 4096); + + return new EmbedBuilder() + .setTitle(geniusSong.title) + .setURL(geniusSong.url) + .setDescription(lyricsText) + .setColor(Colors.Yellow) + .setFooter({ text: i18next.t('commands:lyrics_embed_text_not_correct') }); + } catch (e){ + return generateErrorEmbed(i18next.t('commands:lyrics_embed_lyrics_not_found')); + } } diff --git a/src/commands/audio/lyrics.command.ts b/src/commands/audio/lyrics.command.ts index e8a97c9..56c52ed 100644 --- a/src/commands/audio/lyrics.command.ts +++ b/src/commands/audio/lyrics.command.ts @@ -34,6 +34,7 @@ export default function (): ICommand { execute: async (interaction) => { const songQuery = interaction.options.getString('request')!; + await interaction.deferReply() await interaction.reply({ embeds: [await generateLyricsEmbed(songQuery)] }); } }, diff --git a/wiki/Commands.md b/wiki/Commands.md index cd1769b..d35e438 100644 --- a/wiki/Commands.md +++ b/wiki/Commands.md @@ -100,6 +100,12 @@ Skip current playing song Kill the audioplayer +### lyrics + +Example: /lyrics faded alan walker + +Searching a provided query for song lyrics and return text + ### audiodebug Give the current count of spawned audioplayers