Discord Player
Complete framework to facilitate music commands using discord.js.
Installation
$ npm install --save discord-player
$ npm install --save @discordjs/opus
Install FFmpeg or Avconv
Features
- Simple & easy to use 🤘
- Beginner friendly 😱
- Audio filters 🎸
- Lightweight 🛬
- Custom extractors support 🌌
- Lyrics 📃
- Multiple sources support ✌
- Play in multiple servers at the same time 🚗
Getting Started
Here is the code you will need to get started with discord-player. Then, you will be able to use client.player
everywhere in your code!
const Discord = require("discord.js"),
client = new Discord.Client,
settings = {
prefix: "!",
token: "Your Discord Token"
};
const { Player } = require("discord-player");
const player = new Player(client);
client.player = player;
client.player.on("trackStart", (message, track) => message.channel.send(`Now playing ${track.title}...`))
client.once("ready", () => {
console.log("I'm ready !");
});
client.on("message", async (message) => {
const args = message.content.slice(settings.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if(command === "play"){
client.player.play(message, args[0]);
}
});
client.login(settings.token);
Supported websites
By default, discord-player supports YouTube, Spotify and SoundCloud streams only.
Optional dependencies
Discord Player provides an Extractor API that enables you to use your custom stream extractor with it. Some packages have been made by the community to add new features using this API.
Optional package that adds support for vimeo
, reverbnation
, facebook
, attachment links
and lyrics
.
You just need to install it using npm i --save @discord-player/extractor
(discord-player will automatically detect and use it).
@discord-player/downloader
is an optional package that brings support for +700 websites. The documentation is available here.
Examples of bots made with Discord Player
These bots are made by the community, they can help you build your own!
Advanced
Use cookies
const player = new Player(client, {
ytdlDownloadOptions: {
requestOptions: {
headers: {
cookie: "YOUR_YOUTUBE_COOKIE"
}
}
}
});
Use custom proxies
const HttpsProxyAgent = require("https-proxy-agent");
const proxy = "http://user:pass@111.111.111.111:8080";
const agent = HttpsProxyAgent(proxy);
const player = new Player(client, {
ytdlDownloadOptions: {
requestOptions: { agent }
}
});