From 4bec944e1192a9586559164b5f86eb2b5a553dc5 Mon Sep 17 00:00:00 2001 From: entar Date: Fri, 23 May 2025 06:31:00 +0700 Subject: [PATCH] Removed the helptest command, commented a lot of voice.js and fixed the music downloading into subfolders --- commands/extra.js | 20 -------------------- commands/voice.js | 14 +++++++++++--- 2 files changed, 11 insertions(+), 23 deletions(-) delete mode 100644 commands/extra.js diff --git a/commands/extra.js b/commands/extra.js deleted file mode 100644 index a1dd51c..0000000 --- a/commands/extra.js +++ /dev/null @@ -1,20 +0,0 @@ -const {client} = require("../index") -const { GuildMember, GuildChannel } = require("discord.js") - -module.exports = [ - { - name: "helptest", - description: "Kill every1", - arguments: [GuildMember, GuildChannel], - run: (ctx, member, channel) => { - if (!member || !(member instanceof GuildMember) ) { - return ctx.reply("Member invalid.") - } - if (!channel || !(channel instanceof GuildChannel) ) { - return ctx.reply("Channel invalid.") - } - - ctx.reply(`Member: ${member}\nChannel: ${channel}`) - } - }, -] \ No newline at end of file diff --git a/commands/voice.js b/commands/voice.js index 1713a46..1ca7ce6 100644 --- a/commands/voice.js +++ b/commands/voice.js @@ -25,7 +25,7 @@ module.exports = [ channel = member.voice.channel } - // Returns + // Returns if the user is not in vc or the bot is already in one if (!channel) { return ctx.reply("You are not in a VC right now.") } else if (ctx.guild.members.me.voice.channel && ctx.guild.members.me.voice.channel.id != channel.id) { @@ -47,32 +47,40 @@ module.exports = [ connection = getVoiceConnection(ctx.guild.id) } + // Running yt-dlp (getting music title) const metadata = await ytDlp.getVideoInfo(link); ctx.reply(`Playing ${metadata.title}`) + // Running yt-dlp (downloading music) const music = ytDlp.exec([ + // Arguments to run yt-dlp with link, '-f', 'best', '-o', - `${dir}/music/${metadata.title}.mp3`, + `${dir}/music/'${metadata.title}.mp3'`, '--extract-audio', '--audio-format', 'mp3' ]).on('close', () => { + // Stopping old audioplayer if (players[ctx.guild.id]) { players[ctx.guild.id].stop() } + // Connecting audio player const player = createAudioPlayer() players[ctx.guild.id] = player - const resource = createAudioResource(`${dir}/music/${metadata.title}.mp3`) + // Loading music + const resource = createAudioResource(`${dir}/music/'${metadata.title}.mp3'`) + // Playing the music with the player player.play(resource) + // Subscribing the connection to the player connection.subscribe(player) }) }