【发布时间】:2019-08-18 08:07:58
【问题描述】:
我的 discord 机器人尝试在语音频道中播放 MP3 文件时遇到错误。
我的代码:
if(message.member.voiceChannel){
const connection = await message.member.voiceChannel.join();
const dispatcher = connection.playFile('./resources/shamebell.mp3');
dispatcher.on('finish', () => {
console.log('Finished playing!');
});
dispatcher.destroy(); // end the stream
}
机器人在尝试播放 MP3 文件时遇到错误。它加入了用户所在的语音频道就好了。机器人应该加入 VC,播放 MP3 文件然后离开。
调度程序出错:
TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string
我尝试过使用 MP3 的绝对路径和相对路径。已安装 FFMPEG 并设置了 Windows PATH 以及安装了 NPM “ffmpeg-binaries”:“^3.2.2-3”。
从 connection.playFile('./resources/shamebell.mp3'); 交换到 connection.play('./resources/shamebell.mp3'); 在第 14:43 行给出错误 connection.play is not a function
对于解决此问题的任何帮助将不胜感激:)
安装了 Discordv12 的新代码:
const connection = await message.member.voice.channel.join();
const dispatcher = connection.play('resources/shamebell.mp3');
dispatcher.on('finish', () => {
console.log('Finished playing!');
});
dispatcher.destroy();
同样的问题:
TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string
MP3 文件的路径: C:\Users\Test\Desktop\bot\BotTest\resources\shamebell.mp3
【问题讨论】:
标签: node.js ffmpeg mp3 typeerror discord.js