Discord.js строка playFile является объектом - PullRequest
0 голосов
/ 09 марта 2019
const Discord = require('discord.js');
const client = new Discord.Client();

client.login('token');

client.on('message', message => {
  if (!message.guild) return;

  if (message.content === '/join') {
    if (message.member.voiceChannel) {
      message.member.voiceChannel.join()
        .then(connection => {
          const dispatcher = connection.playFile('C:/Users/hh-hh/Desktop/NODES/DiscordBot/song.mp3')
        })
        .catch(console.log);
    } else {
      message.reply('you must be in the voice channel!');
    }
  }
});

'C: /Users/hh-hh/Desktop/NODES/DiscordBot/song.mp3' - это объект ?? Я сделал это как на https://discord.js.org/#/docs/main/stable/topics/voice странице, но это не работает. Ошибка:

TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received type object
    at validateString (internal/validators.js:125:11)
    at normalizeSpawnArguments (child_process.js:414:3)
    at Object.spawn (child_process.js:553:16)
    at new FfmpegProcess (C:\Users\hh-hh\Desktop\NODES\DiscordBot\node_modules\prism-media\src\transcoders\ffmpeg\FfmpegProcess.js:14:33)
    at FfmpegTranscoder.transcode (C:\Users\hh-hh\Desktop\NODES\DiscordBot\node_modules\prism-media\src\transcoders\ffmpeg\Ffmpeg.js:34:18)
    at MediaTranscoder.transcode (C:\Users\hh-hh\Desktop\NODES\DiscordBot\node_modules\prism-media\src\transcoders\MediaTranscoder.js:27:31)
    at Prism.transcode (C:\Users\hh-hh\Desktop\NODES\DiscordBot\node_modules\prism-media\src\Prism.js:13:28)
    at AudioPlayer.playUnknownStream (C:\Users\hh-hh\Desktop\NODES\DiscordBot\node_modules\discord.js\src\client\voice\player\AudioPlayer.js:97:35)
    at VoiceConnection.playFile (C:\Users\hh-hh\Desktop\NODES\DiscordBot\node_modules\discord.js\src\client\voice\VoiceConnection.js:448:24)
    at message.member.voiceChannel.join.then.connection (C:\Users\hh-hh\Desktop\NODES\DiscordBot\testbot.js:14:41)
...