Unofficial YouTube Music Plugin for DisTube
npm install ytmusic-distube-plugin
const { DisTube } = require("distube");
const { YouTubeMusicPlugin } = require("ytmusic-distube-plugin");
const distube = new DisTube({
plugins: [new YouTubeMusicPlugin()],
});
new YouTubeMusicPlugin({
// Whether to emit events after fetching or not (Default: true)
emitEventsAfterFetching: true,
// Whether to fetch the song/playlist before adding to the queue or not (Default: false)
fetchBeforeQueued: false,
// Whether to process playlist tracks in parallel or sequentially (Default: true)
parallel: true,
// Maximum number of tracks to fetch from playlists, albums, and artists (Default: 10)
maxViews: 10,
});
- YouTube Music video:
https://music.youtube.com/watch?v=xxx
- YouTube Music playlist:
https://music.youtube.com/playlist?list=xxx
- YouTube Music album:
https://music.youtube.com/browse/MPREb_xxx
- YouTube Music artist:
https://music.youtube.com/channel/xxx
- YouTube video:
https://www.youtube.com/watch?v=xxx
// Play YouTube Music
distube.play(voiceChannel, "https://music.youtube.com/watch?v=xxx", options);
// Play a YouTube Music playlist
distube.play(voiceChannel, "https://music.youtube.com/playlist?list=xxx", options);
// Play a YouTube Music album
distube.play(voiceChannel, "https://music.youtube.com/browse/MPREb_xxx", options);
// Play a YouTube Music artist
distube.play(voiceChannel, "https://music.youtube.com/channel/xxx", options);
const song = await distube.search("Hanya Rindu")[0];
distube.play(voiceChannel, song, options);
Related songs can be automatically played when using the plugin with the DisTube's autoplay
feature enabled. It will use this plugin to get related songs from YouTube Music.
// Enable autoplay mode to use related songs
distube.toggleAutoplay(message);
To run the tests:
npm test
This is an unofficial plugin for DisTube. It is not endorsed by or affiliated with DisTube or YouTube Music. This plugin is developed independently to add YouTube Music support to DisTube.
This plugin makes use of the following libraries:
- ytmusic-api - API client for YouTube Music
- @distube/ytdl-core - YouTube video and audio stream downloader
- DisTube - A Discord.js module to simplify your music commands
MIT © abiyyufahri