Skip to content

Commit

Permalink
Merge pull request #13 from Muril-o/fix-music
Browse files Browse the repository at this point in the history
Fix music
  • Loading branch information
Yakiyo authored Jan 26, 2023
2 parents 0be7ca7 + e582c7b commit f594989
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@
"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",
"discord.js": "^14.6.0",
"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"
Expand Down
12 changes: 12 additions & 0 deletions src/commands/music/stop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -52,6 +53,7 @@ const distube = new DisTube(client, {
leaveOnEmpty: true,
leaveOnFinish: true,
leaveOnStop: false,
plugins: [new YtDlpPlugin({ update: true })],
});

client.commandHandler = new CommandHandler();
Expand Down

0 comments on commit f594989

Please sign in to comment.