【发布时间】:2020-02-11 03:30:36
【问题描述】:
我正在尝试播放音频文件,但由于某种原因它没有播放任何内容,它在机器人连接到语音通道后立即触发 end 事件而不是 start 事件。
client.on('message', message => {
if(message.content.startsWith('!play')) {
if(!message.member.voiceChannel) return message.channel.send('connect to voice channel first');
message.member.voiceChannel.join()
.then(connection => {
console.log("Joined voice channel!");
const dispatcher = connection.playFile(require("path").join(__dirname, './myfile.mp3'));
dispatcher.on('start', () => { //not working
dispatcher.setVolume(0.70);
console.log("Playing");
});
dispatcher.on('error', (err) => console.log(err)); //no errors
dispatcher.on('end', end => { //working fine
console.log("Finished");
console.log("End: " + end);
message.member.voiceChannel.leave()
});
});
}});
【问题讨论】:
标签: javascript node.js discord.js