Music Bot doesn't connect to Voice channel

Trying to make a simple music bot that only plays one link, but it doesn't connect to the voice channel, it doesn't give as a result any error so I can't do anything other than put all my code. Here is my Main.js

const {Intents} = require('discord.js');
const Discord = require('discord.js');
const botIntents = [ Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_VOICE_STATES, Intents.FLAGS.GUILD_MEMBERS];
const client = new Discord.Client({ intents: botIntents });
const prefix = '-';
const fs = require('fs');
const teo = "<@---------->";
const aime = "<@------------>";
const pagliac = "Di di no alla vita sociale! Ogni giorno migliaia di gamer perdono i propri amici per questa Vita sociale, Non si sa cosa sia pero se donate una piccola somma di: 4 reni, tua madre e forse anche tua sorella";

client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
    const command = require(`./commands/${file}`);

    client.commands.set(command.name, command);
}

client.once('ready', async () =>{
    console.log('Ready!');
    client.user.setActivity('Tua madre', { type: 'PLAYING' });
})

client.on ('message', 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 === 'embed'){
        client.commands.get('embed').execute(message, args, Discord, client);
    } else if (command === 'pong'){
        message.channel.send('Aime e un pagliaccio, giochiamo a the forest');
    } else if (command === 'teo'){
        for (var i=0; i<5; i++){
            message.channel.send(teo);
        }
    } else if (command === 'aime'){
        for (let s=0; s<5; s++){
            message.channel.send(aime);
            message.channel.send(pagliac);
        }
    } else if (command === 'clear'){
        client.commands.get('clear').execute(message, args);
    } else if (command === 'ping'){
        message.channel.send(`Pingazzo pazzo di: ${Date.now() - message.createdTimestamp}ms. La latenza delle api ${Math.round(client.ws.ping)}ms`);
    } else if (command === 'acqua'){
        const siuum = new Discord.MessageEmbed()
        .setColor('#0011FF')
        .setTitle('Marmellata')
        .setDescription('marmellata')
        const sus = message.mentions.users.first();
        sus.send({embeds: [siuum]});
    } else if(command === 'bully'){
        client.commands.get('bully').execute(message)
    } else if(command === 'aimesus')
        client.commands.get('aimesus').execute(message)

});

Here is my music bot command, i think that it is correct because, i had already asked here, somebody for help.

const ytdl = require('ytdl-core');

module.exports ={
    name:'aimesus',
    description:'aaaaaaaaaaaam',
    execute(message, args){
        const { joinVoiceChannel, createAudioPlayer, createAudioResource, generateDependencyReport, VoiceConnectionStatus } = require('@discordjs/voice');
        const url = 'https://www.youtube.com/watch?v=NevKVKbCNy4&ab_channel=NTDM'
        const stream = ytdl(url, {filter: 'audioonly'});
        const player = createAudioPlayer();
        const resource = createAudioResource(stream);
        const connection = joinVoiceChannel({
            channelId: message.channelid,
            guildId: message.guildid,
            adapterCreator: message.guild.voiceAdapterCreator
        })
        connection.subscribe(player);
        player.play(resource);
        
        console.log(generateDependencyReport());
        
    }
}


from Recent Questions - Stack Overflow https://ift.tt/3F0q1bb
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation