Removed the helptest command, commented a lot of voice.js and fixed the music downloading into subfolders

This commit is contained in:
entar 2025-05-23 06:31:00 +07:00
parent 6b4603f1f7
commit 4bec944e11
2 changed files with 11 additions and 23 deletions

View File

@ -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}`)
}
},
]

View File

@ -25,7 +25,7 @@ module.exports = [
channel = member.voice.channel channel = member.voice.channel
} }
// Returns // Returns if the user is not in vc or the bot is already in one
if (!channel) { if (!channel) {
return ctx.reply("You are not in a VC right now.") 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) { } 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) connection = getVoiceConnection(ctx.guild.id)
} }
// Running yt-dlp (getting music title)
const metadata = await ytDlp.getVideoInfo(link); const metadata = await ytDlp.getVideoInfo(link);
ctx.reply(`Playing ${metadata.title}`) ctx.reply(`Playing ${metadata.title}`)
// Running yt-dlp (downloading music)
const music = ytDlp.exec([ const music = ytDlp.exec([
// Arguments to run yt-dlp with
link, link,
'-f', '-f',
'best', 'best',
'-o', '-o',
`${dir}/music/${metadata.title}.mp3`, `${dir}/music/'${metadata.title}.mp3'`,
'--extract-audio', '--extract-audio',
'--audio-format', '--audio-format',
'mp3' 'mp3'
]).on('close', () => { ]).on('close', () => {
// Stopping old audioplayer
if (players[ctx.guild.id]) { if (players[ctx.guild.id]) {
players[ctx.guild.id].stop() players[ctx.guild.id].stop()
} }
// Connecting audio player
const player = createAudioPlayer() const player = createAudioPlayer()
players[ctx.guild.id] = player 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) player.play(resource)
// Subscribing the connection to the player
connection.subscribe(player) connection.subscribe(player)
}) })
} }