Discord.js: TypeError: this.inputMedia.pipe is not a function

Created on 7 Jun 2019  Â·  2Comments  Â·  Source: discordjs/discord.js

When I try to play a YouTube URL using connection.playStream, I get this error:

TypeError: this.inputMedia.pipe is not a function
    at FfmpegProcess.connectStream (/home/ivan/Documents/project/node_modules/discord.js/node_modules/prism-media/src/transcoders/ffmpeg/FfmpegProcess.js:73:21)
    at new FfmpegProcess (/home/ivan/Documents/project/node_modules/discord.js/node_modules/prism-media/src/transcoders/ffmpeg/FfmpegProcess.js:28:14)
    at FfmpegTranscoder.transcode (/home/ivan/Documents/project/node_modules/discord.js/node_modules/prism-media/src/transcoders/ffmpeg/Ffmpeg.js:34:18)
    at MediaTranscoder.transcode (/home/ivan/Documents/project/node_modules/discord.js/node_modules/prism-media/src/transcoders/MediaTranscoder.js:27:31)
    at Prism.transcode (/home/ivan/Documents/project/node_modules/discord.js/node_modules/prism-media/src/Prism.js:13:28)
    at AudioPlayer.playUnknownStream (/home/ivan/Documents/project/node_modules/discord.js/src/client/voice/player/AudioPlayer.js:97:35)
    at VoiceConnection.playStream (/home/ivan/Documents/project/node_modules/discord.js/src/client/voice/VoiceConnection.js:478:24)
    at voiceChannel.join.then.connection (/home/ivan/Documents/project/commands/play.js:32:47)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Here's my code

const ytdl = require("ytdl-core");

const voiceChannel = message.member.voiceChannel;
if(!voiceChannel) {
    message.channel.send("You need to connect to a voice channel first");
    reject("Not connected to voice channel");
}
const perms = voiceChannel.permissionsFor(message.client.user);
if (!perms.has("CONNECT")) {
    message.channel.send("You need to add the 'connect' permission for this bot");
    reject("NO CONNECT PERMISSION");
}
if (!perms.has("SPEAK")) {
    message.channel.send("You need to add the 'speak' permission for this bot");
    reject("NO SPEAK PERMISSION");
}
const streamOptions = { seek: 0, volume: 1, passes: 2 };
voiceChannel.join()
    .then(connection => {
       const stream = ytdl(args[0], {filter: 'audioonly'});
        const dispatcher = connection.playStream(ytdl, streamOptions);
        dispatcher.on("end", reason => {
            console.log("reason: " + reason);
            voiceChannel.leave();
        })
        dispatcher.on("error", err => {
            console.log(err);
        })
    })
.catch(err => console.log(err));

Further details:

  • discord.js version: 11.5.1
  • Node.js version: 10.16.0
  • opusscript: 0.0.6
  • ffmpeg: 4.1.3-0ubuntu1
  • Operating system: Ubuntu 19.04
  • [ ] I have also tested the issue on latest master, commit hash:
invalid

Most helpful comment

You're trying to play the ytdl module, I think you meant stream

All 2 comments

You're trying to play the ytdl module, I think you meant stream

Ah, yep, my bad. Thanks.

Was this page helpful?
0 / 5 - 0 ratings