我的机器人不会播放音乐。我的代码有问题吗

时间:2019-02-13 22:05:10

标签: javascript node.js discord

根据视频,我已经正确地完成了所有操作,但这似乎无效。

我正在纠正错误,但似乎无济于事

这是我的代码

const Discord = require('discord.js');

const client = new Discord.Client();

const token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';

client.login(token);

const ytdl = require('ytdl-core');
const streamOptions = { seek: 0, volume: 1 };

client.on=('ready', () => {
    console.log("Music Bot is Ready");

});

client.on('message', Message => {
    if(Message.author.bot)
        return;
    if(Message.content.toLowerCase().startsWith("?play"))
    {

        let VoiceChannnel = message.guild.channels.find(channel => channel.id === 'XXXXXXXXXXXXXXXXX');
        if(VoiceChannnel != null)
        {
            console.log(VoiceChannnel.name + " Was found and is a " + VoiceChannnel.type + " channel.");
            VoiceChannnel.join()
            .then(connection =>{
                console.log("Bot joined the channel!");
                const stream = ytdl('https://www.youtube.com/watch?v=XXXXXXXXXX', { filter :'audioonly' });
                const dispatcher = connection.playStream(stream, streamOptions);
            })
            .catch();
        };

    }
});

发现了音乐bot,并且该机器人处于语音通道中

0 个答案:

没有答案