• Stars
    star
    527
  • Rank 84,091 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🎧 Complete framework to simplify the implementation of music commands using discord.js v14

Discord Player

Discord Player is a robust framework for developing Discord Music bots using JavaScript and TypeScript. It is built on top of the discord-voip library and offers a comprehensive set of customizable tools, making it one of the most feature enrich framework in town.

downloadsBadge versionBadge discordBadge

Why Choose Discord Player?

  • Beginner-friendly with easy-to-understand features
  • TypeScript support
  • Offers hackable APIs.
  • Supports audio player sharing
  • Quick and easy setup process
  • Wide range of player management features
  • Offers 64+ built-in audio filter presets
  • Highly customizable according to your needs
  • Automatic queue management
  • Query caching support
  • Extensible sources through the Extractors API
  • Object-oriented design
  • Built-in stats tracker
  • Offers easy debugging methods
  • Out-of-the-box voice states handling

Installation

Before you start

Discord Player requires Discord.js 14.0 or higher. Please ensure that you have a compatible version by running npm list discord.js in your terminal. If you're using an earlier version, please update it. The discord.js Guide provides resources to assist you with the update process.

Main Library

$ npm install --save discord-player # main library
$ npm install --save @discord-player/extractor # extractors provider

Discord Player recognizes @discord-player/extractor and loads it automatically by default. Just invoke await player.extractors.loadDefault().

Opus Library

Since Discord only accepts opus packets, you need to install the opus library. Choose one of the following options:

$ npm install --save @discordjs/opus
# or
$ npm install --save opusscript

FFmpeg or Avconv

FFmpeg or Avconv is required for media transcoding. You can obtain it from https://ffmpeg.org or install it via npm (we recommend against using ffmpeg-static or other binaries):

$ npm install --save ffmpeg-static
# or
$ npm install --save @ffmpeg-installer/ffmpeg
# or
$ npm install --save @node-ffmpeg/node-ffmpeg-installer
# or
$ npm install --save ffmpeg-binaries

Use FFMPEG_PATH environment variable to load ffmpeg from custom path.

Streaming Library

If you want to add support for YouTube playback, you need to install a streaming library. Choose one of the following options:

$ npm install --save ytdl-core
# or
$ npm install --save play-dl
# or
$ npm install --save @distube/ytdl-core
# or
$ npm install --save yt-stream

Once you have completed these installations, let's proceed with writing a simple music bot.

Setup

Let's create a main player instance. This instance handles and keeps track of all the queues and its components.

const { Player } = require('discord-player');

// get some extractors if you want to handpick sources
const { SpotifyExtractor, SoundCloudExtractor } = require('@discord-player/extractor');

const client = new Discord.Client({
    // Make sure you have 'GuildVoiceStates' intent enabled
    intents: ['GuildVoiceStates' /* Other intents */]
});

// this is the entrypoint for discord-player based application
const player = new Player(client);

// This method will load all the extractors from the @discord-player/extractor package
await player.extractors.loadDefault();

// If you dont want to use all of the extractors and register only the required ones manually, use
await player.extractors.register(SpotifyExtractor, {});
await player.extractors.register(SoundCloudExtractor, {});

Discord Player is mostly events based. It emits different events based on the context and actions. Let's add a basic event listener to notify the user when a track starts to play:

// this event is emitted whenever discord-player starts to play a track
player.events.on('playerStart', (queue, track) => {
    // we will later define queue.metadata object while creating the queue
    queue.metadata.channel.send(`Started playing **${track.title}**!`);
});

Let's move on to the command part. You can define the command as per your requirements. We will only focus on the command handler part:

async function execute(interaction) {
    const channel = interaction.member.voice.channel;
    if (!channel) return interaction.reply('You are not connected to a voice channel!'); // make sure we have a voice channel
    const query = interaction.options.getString('query', true); // we need input/query to play

    // let's defer the interaction as things can take time to process
    await interaction.deferReply();

    try {
        const { track } = await player.play(channel, query, {
            nodeOptions: {
                // nodeOptions are the options for guild node (aka your queue in simple word)
                metadata: interaction // we can access this metadata object using queue.metadata later on
            }
        });

        return interaction.followUp(`**${track.title}** enqueued!`);
    } catch (e) {
        // let's return error if something failed
        return interaction.followUp(`Something went wrong: ${e}`);
    }
}

That's all it takes to build your own music bot. Please check out the Documentation for more features/functionalities.

Community Resources

Explore a curated list of resources built by the Discord Player community, including open-source music bots and extractors. Visit https://discord-player.js.org/showcase for more information.

More Repositories

1

AtlantaBot

🤖 Another powerful Discord Bot with a web-dashboard used by more than 130k users!
JavaScript
845
star
2

discord-data-package-explorer

🌀 What's really in your Discord Data package?
Svelte
828
star
3

discord-backup

📦 Complete framework to facilitate server backup using discord.js v13
TypeScript
411
star
4

scratch-for-discord

🐱Create your own Discord Bot easily using Scratch-styled blocks! Made with Vue.js
JavaScript
341
star
5

discord-giveaways

🎉 Complete framework to facilitate the creation of giveaways using discord.js
JavaScript
335
star
6

discord-logs

📝Framework that simplify the usage of advanced Discord logs
TypeScript
243
star
7

discord-music-bot

The perfect music bot for your Discord server! 🤘
JavaScript
238
star
8

discord-giveaways-bot

🎁Giveways Bot using the discord-giveaways package
JavaScript
201
star
9

insta.js

💬 Object-oriented library for sending and receiving messages via Instagram
JavaScript
137
star
10

slash-commands-gui

GUI tool to explore Slash Commands of your bot, built on Vue 3 and TailwindCSS 🚀
Vue
131
star
11

vinted-discord-bot

🔔 BOT Discord qui envoie un message quand un nouvel article est publié sur Vinted (selon certains critères)
TypeScript
115
star
12

discord-temp-channels

Simple framework to facilitate the creation of a temporary voice channels system using Discord.js
TypeScript
113
star
13

DiscordYoutubeNotifier

Be notified when one of your favorite youtubers posts a video!
JavaScript
100
star
14

discord-invites-tracker

🐕 Track Discord invites to know who invited who and with which invite!
TypeScript
94
star
15

DiscordEconomyBot

A very simple bot with an economy system using the Discord.js API
JavaScript
87
star
16

vinted-api

JavaScript library to interact with the Vinted API
JavaScript
84
star
17

backups-bot

🌟 Backups Bot using the discord-backup package
JavaScript
78
star
18

minecraft-discord-bot

📊View the status and statistics of your MC server directly on Discord!
JavaScript
65
star
19

stripe-discord-bot

Discord bot to give a role to users paying a Stripe subscription
TypeScript
39
star
20

node-ecole-directe

Connexion à école directe sans passer par l'interface web!
JavaScript
38
star
21

instaddict

💊  How addicted are you to Instagram?
Svelte
37
star
22

paypal-bot

Générez des liens de factures et acceptez des paiements sur Discord!
CSS
32
star
23

pronote-bot

😎 Chatbot Instagram pour Pronote
JavaScript
30
star
24

paypal-api

💰Node.js package to interact with PayPal REST API
TypeScript
30
star
25

discord-bot-template

Custom Discord Bot template for my bots 🚀
TypeScript
29
star
26

discord-sync-commands

Easily keep your bot's slash commands synchronized with Discord
JavaScript
28
star
27

pronote-bot-discord

Un bot Discord pour envoyer les nouveaux devoirs dans un serveur Discord 📚
JavaScript
26
star
28

easy-json-database

📂 Easy to use json database. Used for Scratch For Discord.
JavaScript
26
star
29

tiktok-discord-bot

Simple Discord Bot that sends notifications on new TikTok posts
JavaScript
23
star
30

Sworder-Dashboard.io

🌐 Discord bot dashboard created by Sworder71
HTML
23
star
31

discbot.js

🚀 Powerful discord bot template, for a solid structure!
JavaScript
22
star
32

multilingual-discord-bot

A multilingual discord bot
JavaScript
22
star
33

nfts-discord-bot

✨ Get notified when an item is sold or listed on Solanart and MagicEden!
JavaScript
19
star
34

status

📈 Uptime monitor and status page for Upptime, powered by @upptime
Markdown
18
star
35

auto-github-bio

📚Automatized Github biography using openweathermap.org API
Python
18
star
36

simsimi-bot

Simsimi Discord Bot - The most clever chatbot
CoffeeScript
17
star
37

twitchdl

Download videos (and sub-only videos) from Twitch
JavaScript
16
star
38

arduino-is-mybot-online

🚨 Simple status LED with Arduino to alert you if your bot is down!
C++
13
star
39

pronote-qrcode-api

🧪 Stuff about Pronote QRCodes to connect using a mobile phone
JavaScript
13
star
40

AutoBanSelfbots

A bot that automatically detects selfbots and ban them
JavaScript
12
star
41

stop-fake-discord-friends

JavaScript
11
star
42

blog.androz2091.fr

✏️ My personal blog, built with Gatsby 2
MDX
11
star
43

wot-stats-bot

Discord bot that displays your World Of Tanks stats!
JavaScript
11
star
44

twittycord

Open source online service to verify Discord users social connections
TypeScript
10
star
45

AndrozDevBot

Official bot for the AndrozDev server
JavaScript
9
star
46

my-insta-stats

🚧 Instagram version of Discord Data Package Explorer. Under development.
Svelte
9
star
47

github-issues-discord-bot

Convert Discord messages to GitHub issues!
TypeScript
9
star
48

Atlantav2

The V2 of Atlanta. Don't judge please.
JavaScript
8
star
49

rockstar-games-status

Simple package to get the current status of Rockstar Games services
JavaScript
8
star
50

npm-files-explorer

Adds a button to browse files of a package on NPM
JavaScript
8
star
51

atlanta-emojis-mod

Moderator bot for the Atlanta Emojis servers
JavaScript
7
star
52

deno-diswho

Deno port of Diswho
JavaScript
7
star
53

androz2091.fr

👋 My personal website
HTML
6
star
54

Cicero

Great speaker, Cicero is a text-to-speech Discord Bot!
TypeScript
6
star
55

neko-love

🐱A Neko Love API wrapper !
TypeScript
6
star
56

floor-price-bot

Powerful bot that fetches floor prices from OpenSea and send them on Discord 🚀
TypeScript
6
star
57

disable-discord-notifications

Script that disable notifications for each of your servers
JavaScript
6
star
58

Androz2091

6
star
59

k8s-infrastructure

🕸️ 🚀 My personal server infrastructure - kubernetes cluster - ArgoCD, Longhorn, Kubeseal, Caddy
Shell
6
star
60

chess-ai-discord-bot

JavaScript
5
star
61

easy-discord-commands

Simple framework to create commands using Discord.js
TypeScript
5
star
62

pixpay-api

🏦 Reverse engineering of the PixPay Private API
JavaScript
5
star
63

fiverr-hmsip

Fiverr, How Much Should I Pay? chrome extension
JavaScript
5
star
64

dotapps

Exhaustive list of all the apps I use on my different devices
Ruby
5
star
65

androz2091-cors-anywhere

My own cors-anywhere proxy server
JavaScript
5
star
66

backups-manager

⚡ Gère vos fichiers de sauvegarde de manière intelligente.
Ruby
5
star
67

sleepingmoney-pushover

Realtime notifications from SleepingMoney using Pushover 🌩️
JavaScript
5
star
68

chatgpt-data-package-explorer

Get statistics about your ChatGPT usage
JavaScript
5
star
69

bereal-api

4
star
70

funcraft

🌐 Scrape data from funcraft.net easily!
JavaScript
4
star
71

plex.js

4
star
72

cloudflare-page-rules

Simple package to update cloudflare page rules dynamically
JavaScript
4
star
73

steam-usernames-scraper

Check a list of Steam usernames
JavaScript
4
star
74

diswho

Simple API to get information about a Discord user or a Discord invite
Go
4
star
75

arte-dl

Download ARTE.tv videos online, for free without any ads
HTML
4
star
76

blague.xyz

Wrapper pour Blague.xyz (blagues aléatoires, blague du jour, etc...)
TypeScript
4
star
77

marche-pala-bot

Le bot pour le serveur Marché Paladium | Paladium | V6
JavaScript
3
star
78

voice-user-bots

TypeScript
3
star
79

slowmode-discord-bot

🐌 Discord bot that allows you to set slowmodes in specific channels of your server
TypeScript
3
star
80

opm-partners-api

TypeScript
3
star
81

coders-bot

Coder's bot, a discord bot for developers written in V
V
3
star
82

export-my-fiverr-orders

JavaScript
3
star
83

milou

🐶🐶
EJS
3
star
84

bento-custom-domain

JavaScript
3
star
85

tradingview-bot

JavaScript
2
star
86

cyanide-happiness-bot

Bot pour le Discord Cyanide and Happiness VF
JavaScript
2
star
87

customgpt-discord-bot

JavaScript
2
star
88

expressio.fr

Obtenez des expressions aléatoires de expressio.fr
JavaScript
2
star
89

ljdc-bot

Un bot Discord qui affiche une image aléatoire du site lesjoiesducode.fr
JavaScript
2
star
90

ohorime

ohorime bot
JavaScript
2
star
91

imgur-app

Simple Flutter app to browse your imgur images
Dart
2
star
92

discord-code-generator

HTML
2
star
93

hello-world

JavaScript
2
star
94

kevintrades-discord-bot

TypeScript
2
star
95

discord-asker

A very simple package to easily use Discord collectors
2
star
96

liste-celebrites

Une liste de ~150 célébrités, dont certaines françaises, au format JSON.
2
star
97

kampios-discord-bot

TypeScript
2
star
98

slowmode-discordeno-bot

🐌 Slowmode Discord Bot rewritten for Deno
TypeScript
2
star
99

beefast

App iOS native pour comprendre comment fonctionne Storyboard, Xcode et les bases du Swift.
Swift
2
star
100

discord-whook.js

A simple discord webhook wrapper.
JavaScript
2
star