brackets-archive / bracketsIssues

Archive of issues in brackets.
0 stars 0 forks source link

[CLOSED] Trying to make a music discord bot, but the music don't play. #12134

Open core-ai-bot opened 3 years ago

core-ai-bot commented 3 years ago

Issue by CyberByte-js Wednesday Sep 16, 2020 at 20:34 GMT Originally opened as https://github.com/adobe/brackets/issues/15213


Making a discord music bot in Discord.js but the play command doesn't works. The bot enters in the voice chat but don't say nothing.

index.js `const Discord = require('discord.js'); const {Client, Attachment, MessageEmbed } = require('discord.js'); const bot = new Client(); const ms = require('ms'); const Ytdl = require('ytdl-core')

const fs = require('fs'); bot.commands = new Discord.Collection(); const commandFiles = fs.readdirSync('./comandos/').filter(file => file.endsWith('.js')); for(const file of commandFiles) { const command = require(./comandos/${file}); bot.commands.set(command.name, command); }

const token = 'TOKEN';

const PREFIX = '%';

var versão = '0.01';

const usedCommandRecently = new Set();

bot.on('ready', () => { console.log('Esse bot está online!'); bot.user.setPresence( { activity: { name: 'Assista e ganhe dinheiro de graça :D', type: "STREAMING", url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstleyVEVO" } }); })

bot.on('guildMemberAdd', member => { const channel = member.guild.channels.cache.find(channel => channel.name === "boas-vindas"); if(!channel) return;

const Embed = new Discord.MessageEmbed()
    .setColor('#ff3f34')
    .setTitle('Bem-vindo!')
    .setAuthor('Bot de Boas-Vindas')
    .setDescription(`Bem-vindo, ${member}, se divirta no nosso servidor!`)
    .setThumbnail('https://lh3.googleusercontent.com/proxy/4aBCSj9lo2dv65tBknbAzPaf-29LxNA38p6XqC8tcXl3qhGN-iBpFnsYQeJgU8XHSGi27BR4urrpGrSyZJ3Gj3jFIppf-ED_3-krLHJSfZ_JIdWyt3UoNRYq49zKsHk5SfGCnpw')

channel.send(Embed)

});

bot.on('message', async message => { if(!message.content.startsWith(PREFIX) || message.author.bot) return;

const args = message.content.slice(PREFIX.length).split(/ +/);
const command = args.shift().toLowerCase();

if(command === 'ping')
{
    bot.commands.get('ping').execute(message, args);            
} else if(command === 'kick')
{
    bot.commands.get('kick').execute(message, args);
} else if(command === 'ban')
{
    bot.commands.get('ban').execute(message, args);
} else if(command === 'd6')
{
    message.channel.send(message.author.username + ' rolou um ' + (Math.floor(Math.random() * 6)));
} else if(command === 'd20')
{
    message.channel.send(message.author.username + ' rolou um ' + (Math.floor(Math.random() * 20)));
} else if(command === 'd100')
{
    message.channel.send(message.author.username + ' rolou um ' + (Math.floor(Math.random() * 100)));
} else if(command === 'ajuda')
{
    bot.commands.get('ajuda').execute(message, args);
} else if(command === 'join')
{
    bot.commands.get('join').execute(message, args);
} else if(command === 'leave')
{
    bot.commands.get('leave').execute(message, args);
} else if(command === 'play')
{
    bot.commands.get('play').execute(message, args);
}

});

bot.login(token);`

play.js `async function start() { let connection = await message.member.voice.channel.join() }

module.exports = { name: 'play', description: "Toque uma música!", execute(message, args) { let estouPronto = false;

    if (message.content.startsWith('%play '))
        {
            if (estouPronto)
            {
                let oQueTocar = message.content.replace('%play ','');
                if(Ytld.validateURL(oQueTocar))
                {
                    message.member.voice.channel.connection.play(Ytld());
                } else
                {
                    message.reply('Esse link não é um vídeo do youtube!')
                }
            }
        }
}

}` Any type of help would be apreciated.

core-ai-bot commented 3 years ago

Comment by florianjr Saturday Sep 26, 2020 at 10:41 GMT


This is not related to this project.

core-ai-bot commented 3 years ago

Comment by jrynd Wednesday Nov 11, 2020 at 00:21 GMT


You should ask on stackoverflow.com