不和谐音乐机器人问题

时间:2018-09-21 20:08:31

标签: javascript discord.js

所以我正在为服务器制作一个不和谐的机器人,我的音乐代码遇到了一些问题! 代码位于here

当我运行机器人时,它运行良好,但是当我执行!play命令时,它会引发以下错误:

Error: FFMPEG not found

如果有人可以帮助我,我会很感激。谢谢您的宝贵时间。

client.on('message', async msg => {
if (msg.author.bot) return undefined;
if (!msg.content.startsWith(prefix)) return undefined;
const args = msg.content.split(' ');

if (msg.content.startsWith(`${prefix}play`)) {
    const voiceChannel = msg.member.voiceChannel;
    if (!voiceChannel) return msg.channel.send('Tens de estár numa sala para eu poder entrar!');
    const permissions = voiceChannel.permissionsFor(msg.client.user);
    if (!permissions.has('CONNECT')) {
        return msg.channel.send('Só podes tocar musica no canal de Musica!')
    }
    if (!permissions.has('SPEAK')) {
        return msg.channel.send('Não posso tocar musica nesse canal!')
    }

    try {
        var connection = await voiceChannel.join();
    } catch (error) {
        console.error(`Não consigo entrar no canal porque: ${error}`);
        return msg.channel.send(`Não consigo entrar no canal de voz: ${error}`);
    }

    const dispatcher = connection.playStream(ytdl(args[1]))
        .on('end', () => {
            console.log('Acabou a musica');
            voiceChannel.leave();
        })
        .on('error', error => {
            console.error(error);
        });
    dispatcher.setVolumeLogarithmic(5 / 5);

} else if (msg.content.startsWith(`${prefix}stop`)) {
    if (msg.member.voiceChannel) return msg.channel.send('Não estás no canal');
    msg.member.voiceChannel.leave();
    return undefined;
}
});

client.login(token);`

1 个答案:

答案 0 :(得分:0)

似乎您尚未安装ffmpeg。

您可以在此处找到有关如何安装ffmpeg并将其添加到路径的简单教程:

https://www.wikihow.com/Install-FFmpeg-on-Windows

安装ffmpeg之后,还需要使用npm安装它,如下所示:

npm install ffmpeg
相关问题