Git Product home page Git Product logo

discord-player's Introduction

Discord Player

Complete framework to facilitate music commands using discord.js.

downloadsBadge versionBadge discordBadge

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");

// Create a new Player (you don't need any API Key)
const player = new Player(client);

// To easily access the player
client.player = player;

// add the trackStart event so when a song will be played this message will be sent
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();

    // !play Despacito
    // will play "Despacito" in the voice channel
    if(command === "play"){
        client.player.play(message, args[0]);
        // as we registered the event above, no need to send a success message here
    }

});

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");

// Remove "user:pass@" if you don't need to authenticate to your proxy.
const proxy = "http://user:[email protected]:8080";
const agent = HttpsProxyAgent(proxy);

const player = new Player(client, {
    ytdlDownloadOptions: {
        requestOptions: { agent }
    }
});

discord-player's People

Contributors

androz2091 avatar dependabot-preview[bot] avatar twlite avatar dongsu8142 avatar casperiv0 avatar 416rehman avatar tasooneasia avatar sagudev avatar zackradisic avatar tjrgg avatar toledosdl avatar thomasthebro1 avatar thaddeuskkr avatar skick1234 avatar simonleclere avatar imlinguin avatar lrxrn avatar brennop avatar orangebae avatar akumakitty avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.