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/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({ diff --git a/src/index.ts b/src/index.ts index 6615f25..276fe0f 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,7 @@ const distube = new DisTube(client, { leaveOnEmpty: true, leaveOnFinish: true, leaveOnStop: false, + plugins: [new YtDlpPlugin({ update: true })], }); client.commandHandler = new CommandHandler();