DEPRECATED
lavacord, a set of packages that aims to give great music support to your Discord bot using Lavalink. Furthermore, we also no longer support the development of Discord.JS in favor of @klasa/core
Work on this package has stopped in favor ofProject Status
Bundle Sizes
Social Media and Donations
For compatible videos, this module uses prism-media to extract Opus or Vorbis audio from a stream without having to pipe it through FFmpeg first. This greatly reduces the processing power required, making playback smoother and allowing you to play over more connections simultaneously.
For videos where the required codec (webm + opus) isn't available, the module will fallback to using FFmpeg to encode the stream in Opus. Many new videos on YouTube are available in this codec so hopefully this isn't frequent.
Put simply, this module finds the most efficient way to extract a stream of Opus or Vorbis audio from a YouTube video.
Install
yarn add @favware/ytdl-prismplayer ytdl-core prism-media
# npm install @favware/ytdl-prismplayer ytdl-core prism-media
# ytdl-core and prism-media are mandatory peer dependencies
Usage
Usage depends on the version of Discord.JS you are using, examples below. You can pass the exact same arguments as you would with the ytdl-core module, with the exception that you must await
the function call.
Usage in Discord.js 11.x
const ytdl = require('@favware/ytdl-prismplayer');
// import ytdl from '@favware/ytdl-prismplayer'
async function play(connection, url) {
connection.playOpusStream(await ytdl(url));
}
Usage in Discord.js 12.x / main
const ytdl = require('@favware/ytdl-prismplayer');
// import ytdl from '@favware/ytdl-prismplayer'
async function play(connection, url) {
connection.play(await ytdl(url), {
type: 'opus'
});
}
// You can prefer vorbis instead of opus
async function play(connection, url) {
connection.play(await ytdl(url, {}, { preferredFormat: 'vorbis' }), {
type: 'opus'
});
}