【问题标题】:Discord music bot issue不和谐音乐机器人问题
【发布时间】:2019-02-26 06:19:08
【问题描述】:

所以我正在为我的服务器制作一个不和谐的机器人,但我的音乐代码有一些问题! 代码位于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);`

【问题讨论】:

  • 你安装了ffmpeg吗?

标签: javascript discord.js


【解决方案1】:

你好像没有安装ffmpeg。

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

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

在你安装完 ffmpeg 之后,还需要像这样用 npm 安装它:

npm install ffmpeg

【讨论】:

    猜你喜欢
    • 2019-08-03
    • 2019-04-04
    • 2020-06-20
    • 2018-08-24
    • 2021-11-24
    • 1970-01-01
    • 2020-09-23
    • 2020-11-01
    • 2021-05-23
    相关资源
    最近更新 更多