无法使用Discord Bot播放链接中的音频

时间:2020-03-02 21:41:01

标签: javascript ffmpeg discord discord.js

我正在尝试编写机器人代码,以便我和我的朋友可以在我们的Discord Server上听到本地广播,但是我遇到此错误。

这是我的代码的一部分,它是处理播放内容的play.js文件。

module.exports = (client,message) => {

const voiceChannel = message.member.voiceChannel;
const idChannel = voiceChannel.id;

console.log(idChannel)
    //vê se o user está numa sala de voz
if(!voiceChannel) {
    return message.channel.send("Precisas de estar num voice channel para usar este comando.")
}
const permissions = voiceChannel.permissionsFor(message.client.user);

 //vê se tem permissões para entrar na sala
if(!permissions.has('CONNECT') || !permissions.has('SPEAK')) {
    return message.channel.send("Não tenho permissões para entrar nessa sala.")
}

voiceChannel.join()
    .then(connection => {
        console.log("Successfully connected.");
        connection.playStream('http://centova.radios.pt:8401/stream.mp3/1')
}).catch(e =>{
    console.error(e);

});

}

这是我得到的错误:

TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received an instance of         
Object
at validateString (internal/validators.js:117:11)
at normalizeSpawnArguments (child_process.js:406:3)
at Object.spawn (child_process.js:542:16)
at new FfmpegProcess (C:\Users\guilh\desktop\BOT\orbitalbot\node_modules\prism-media\src\transcoders\ffmpeg\FfmpegProcess.js:14:33)
at FfmpegTranscoder.transcode (C:\Users\guilh\desktop\BOT\orbitalbot\node_modules\prism-media\src\transcoders\ffmpeg\Ffmpeg.js:34:18)
at MediaTranscoder.transcode (C:\Users\guilh\desktop\BOT\orbitalbot\node_modules\prism-media\src\transcoders\MediaTranscoder.js:27:31)
at Prism.transcode (C:\Users\guilh\desktop\BOT\orbitalbot\node_modules\prism-media\src\Prism.js:13:28)
at AudioPlayer.playUnknownStream (C:\Users\guilh\desktop\BOT\orbitalbot\node_modules\discord.js\src\client\voice\player\AudioPlayer.js:97:35)
at VoiceConnection.playStream (C:\Users\guilh\desktop\BOT\orbitalbot\node_modules\discord.js\src\client\voice\VoiceConnection.js:546:24)
at C:\Users\guilh\desktop\BOT\orbitalbot\commands\play.js:24:24 {
  code: 'ERR_INVALID_ARG_TYPE'

0 个答案:

没有答案