From 8fb5f100b7487a547e7059a8c16bbb7bdb0c248e Mon Sep 17 00:00:00 2001 From: Muril-o Date: Thu, 26 Jan 2023 14:39:53 -0300 Subject: [PATCH 1/3] fix: music isn't playing when running in the vps --- package.json | 3 ++- src/index.ts | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 47d5b06..720ec68 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "dependencies": { "@discordjs/opus": "^0.8.0", "@discordjs/voice": "^0.14.0", + "@distube/yt-dlp": "^1.1.3", "@napi-rs/canvas": "^0.1.30", "@naval-base/ms": "^3.1.0", "@prisma/client": "^4.8.1", @@ -36,9 +37,9 @@ "distube": "^4.0.4", "dotenv": "^16.0.3", "ffmpeg-static": "^4.2.7", + "libsodium-wrappers": "0.7.10", "node-fetch": "2.6.7", "pino": "^7.0.0-rc.9", - "libsodium-wrappers": "0.7.10", "sourcebin": "^5.0.0", "tslib": "^2.4.1", "undici": "^5.14.0" diff --git a/src/index.ts b/src/index.ts index 6615f25..f1da019 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,6 +6,7 @@ import { Partials, } from 'discord.js'; import { DisTube } from 'distube'; +import { YtDlpPlugin } from '@distube/yt-dlp'; import { PrismaClient } from '@prisma/client'; import { CommandHandler } from './struct/commandHandler'; import { EventHandler } from './struct/eventHandler'; @@ -52,6 +53,11 @@ const distube = new DisTube(client, { leaveOnEmpty: true, leaveOnFinish: true, leaveOnStop: false, + plugins: [ + new YtDlpPlugin( + { update: true } + ) + ] }); client.commandHandler = new CommandHandler(); From 7a38f180faef48bcc20bc06abdab92a4499696d2 Mon Sep 17 00:00:00 2001 From: Muril-o Date: Thu, 26 Jan 2023 14:45:11 -0300 Subject: [PATCH 2/3] fix: handle music stop command when there is no current queue --- src/commands/music/stop.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/commands/music/stop.ts b/src/commands/music/stop.ts index 96307ea..a92b634 100644 --- a/src/commands/music/stop.ts +++ b/src/commands/music/stop.ts @@ -7,6 +7,18 @@ export const command: Command = { .setDescription('Stops the music player and disconnects bot from vc'), async execute(interaction) { await interaction.deferReply(); + const queue = distube.getQueue(interaction.guildId as string); + if (!queue) { + interaction.editReply({ + embeds: [ + { + description: + 'No song in the queue at the moment. Use `/play` to add music to the queue.', + }, + ], + }); + return; + } await distube.stop(interaction.guild as Guild); distube.voices.get(interaction.guildId as string)?.leave(); interaction.editReply({ From e582c7b601edcb3b53eb90626866008caa346b4b Mon Sep 17 00:00:00 2001 From: Muril-o Date: Thu, 26 Jan 2023 15:01:33 -0300 Subject: [PATCH 3/3] style: rome fix --- src/index.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index f1da019..276fe0f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -53,11 +53,7 @@ const distube = new DisTube(client, { leaveOnEmpty: true, leaveOnFinish: true, leaveOnStop: false, - plugins: [ - new YtDlpPlugin( - { update: true } - ) - ] + plugins: [new YtDlpPlugin({ update: true })], }); client.commandHandler = new CommandHandler();