【发布时间】: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