【发布时间】:2020-09-04 07:05:52
【问题描述】:
我的代码到达第 24 行 const dispatcher = connection.play('/sounds/Pigstep.mp3', { volume: 0.9 });,我知道这是因为第 26 行的 console.log('audio is now playing!') 被执行。机器人确实进入了语音频道,但它不播放歌曲。我在终端中没有收到任何错误消息。
我的机器人有权加入语音频道并讲话。 我已安装 ffmpeg 并添加到路径中。
这是我的代码:
const Discord = require('discord.js');
const auth = require('./auth.json');
const ytdl = require('ytdl-core');
const client = new Discord.Client();
client.login(auth.token);
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}`);
console.log('Ready!');
});
client.on('message', async msg => {
if (msg.content.substring(0, 1) === '!') {
console.log('Message received!');
let args = msg.content.substring(1).split(' ');
const cmd = args[0];
args = args.splice(1);
switch (cmd) {
case 'cricket':
var connection = await msg.member.voice.channel.join();
const dispatcher = connection.play('/sounds/Pigstep.mp3', { volume: 0.9 });
dispatcher.on('start', () => {
console.log('audio is now playing!');
});
console.log('Playing!');
break;
}
}
});
提前感谢您的帮助:)
【问题讨论】:
-
第22行是哪一行?
-
这是
console.log('audio is now playing!');第26行吗? -
是的,我也会将其添加到问题中
-
你安装了FFMPEG吗?
-
@EvanSmith 是的,我已经安装并添加到我的路径中,在我收到它无法找到 ffmpeg 的错误之前,但通过安装它已解决。
标签: javascript bots discord.js