All Projects → Androz2091 → Discord Player

Androz2091 / Discord Player

Licence: mit
🎧 Complete framework to simplify the implementation of music commands using discords.js v12

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Discord Player

Distube
A Discord.js v12 module to simplify your music commands and play songs with audio filters on Discord without any API key. Support YouTube, SoundCloud, Bandcamp, Facebook, and 700+ more sites
Stars: ✭ 73 (-54.66%)
Mutual labels:  bot, search, music, discord, youtube
Scrape Youtube
A lightning fast package to scrape YouTube search results. This was made and optimized for Discord Bots.
Stars: ✭ 43 (-73.29%)
Mutual labels:  bot, search, discord, youtube
Discord.js Musicbot Addon
This DOES NOT WORK any more. This repo only serves as an archive for is anyone wants to pickup my work. You may still join the discord however.
Stars: ✭ 109 (-32.3%)
Mutual labels:  bot, music, discord, youtube
Automod Bot
Fun moderation economy bot discord.js
Stars: ✭ 41 (-74.53%)
Mutual labels:  bot, music, discord
Pvpcraft
PvPCraft Discord bot
Stars: ✭ 29 (-81.99%)
Mutual labels:  bot, music, discord
Jeelangamusic
Discord bot with music functional. Play, skip, save music and etc!
Stars: ✭ 40 (-75.16%)
Mutual labels:  music, discord, youtube
Smd
Spotify Music Downloader
Stars: ✭ 822 (+410.56%)
Mutual labels:  bot, music, youtube
Create Discord Bot
Create Discord bots using a simple widget-based framework.
Stars: ✭ 70 (-56.52%)
Mutual labels:  bot, framework, discord
Core
The core YAMDBF Framework
Stars: ✭ 63 (-60.87%)
Mutual labels:  bot, framework, discord
Misaki
Misaki is Discord Bot designed for communities with commands ranging from gif based anime reactions, to head scratching trivia commands.
Stars: ✭ 78 (-51.55%)
Mutual labels:  bot, music, discord
Skyra
All-in-one multipurpose Discord Bot designed to carry out most of your server's needs with great performance and stability.
Stars: ✭ 92 (-42.86%)
Mutual labels:  bot, music, discord
Clinet
Official repository for Clinet, a Discord bot intended for assistance and control within your guilds.
Stars: ✭ 28 (-82.61%)
Mutual labels:  bot, discord, youtube
Pixie
An open-source Discord bot built for weebs, by a weeb.
Stars: ✭ 20 (-87.58%)
Mutual labels:  bot, music, discord
Discord.js Menu
💬 Easily create Discord.js v12 embed menus with reactions and unlimited customizable pages.
Stars: ✭ 89 (-44.72%)
Mutual labels:  bot, framework, discord
Pengubot
Official PenguBot GitHub Repository
Stars: ✭ 98 (-39.13%)
Mutual labels:  bot, music, discord
Focabot
Music with seals!
Stars: ✭ 19 (-88.2%)
Mutual labels:  bot, music, discord
Commando
Official command framework for discord.js
Stars: ✭ 434 (+169.57%)
Mutual labels:  bot, framework, discord
Fredboat
A Discord music bot sharing 1 million servers with 20 million users
Stars: ✭ 471 (+192.55%)
Mutual labels:  bot, music, discord
Botify
Discord bot that plays Spotify tracks and YouTube videos or any URL including Soundcloud links and Twitch streams
Stars: ✭ 86 (-46.58%)
Mutual labels:  music, discord, youtube
Music Bot
Simple music bot with a full-blown queue system that is easy to understand
Stars: ✭ 102 (-36.65%)
Mutual labels:  bot, music, discord

Discord Player

downloadsBadge versionBadge

Note: this module uses recent discordjs features and requires discord.js version 12 and Node.js 14.

Discord Player is a powerful Node.js module that allows you to easily implement music commands. Everything is customizable, and everything is done to simplify your work without limiting you! It doesn't require any api key, as it uses scraping.

Installation

npm install --save discord-player

Install @discordjs/opus:

npm install --save @discordjs/opus

Install FFMPEG and you're done!

Features

🤘 Easy to use!
🎸 You can apply some cool filters (bassboost, reverse, 8D, etc...)
🎼 Manage your server queues with simple functions (add songs, skip the current song, pause the music, resume it, etc...)!
🌐 Multi-servers support

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.on("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 member 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);

Documentation

You will find many examples in the documentation to understand how the package works!

Methods overview

You need to init the guild queue using the play() function, then you are able to manage the queue and the music using the following functions. Click on a function name to get an example code and explanations.

Play a track

Check if a track is being played

Manage the queue

Manage music stream

Utils

Event messages

// Then add some messages that will be sent when the events will be triggered
client.player

// Send a message when a track starts
.on('trackStart', (message, track) => message.channel.send(`Now playing ${track.title}...`))

// Send a message when something is added to the queue
.on('trackAdd', (message, queue, track) => message.channel.send(`${track.title} has been added to the queue!`))
.on('playlistAdd', (message, queue, playlist) => message.channel.send(`${playlist.title} has been added to the queue (${playlist.tracks.length} songs)!`))

// Send messages to format search results
.on('searchResults', (message, query, tracks) => {

    const embed = new Discord.MessageEmbed()
    .setAuthor(`Here are your search results for ${query}!`)
    .setDescription(tracks.map((t, i) => `${i}. ${t.title}`))
    .setFooter('Send the number of the song you want to play!')
    message.channel.send(embed);

})
.on('searchInvalidResponse', (message, query, tracks, content, collector) => {

    if (content === 'cancel') {
        collector.stop()
        return message.channel.send('Search cancelled!')
    }

    message.channel.send(`You must send a valid number between 1 and ${tracks.length}!`)

})
.on('searchCancel', (message, query, tracks) => message.channel.send('You did not provide a valid response... Please send the command again!'))
.on('noResults', (message, query) => message.channel.send(`No results found on YouTube for ${query}!`))

// Send a message when the music is stopped
.on('queueEnd', (message, queue) => message.channel.send('Music stopped as there is no more music in the queue!'))
.on('channelEmpty', (message, queue) => message.channel.send('Music stopped as there is no more member in the voice channel!'))
.on('botDisconnect', (message) => message.channel.send('Music stopped as I have been disconnected from the channel!'))

// Error handling
.on('error', (error, message) => {
    switch(error){
        case 'NotPlaying':
            message.channel.send('There is no music being played on this server!')
            break;
        case 'NotConnected':
            message.channel.send('You are not connected in any voice channel!')
            break;
        case 'UnableToJoin':
            message.channel.send('I am not able to join your voice channel, please check my permissions!')
            break;
        case 'LiveVideo':
            message.channel.send('YouTube lives are not supported!')
            break;
        case 'VideoUnavailable':
            message.channel.send('This YouTube video is not available!');
            break;
        default:
            message.channel.send(`Something went wrong... Error: ${error}`)
    }
})

Examples of bots made with discord-player

These bots are made by the community, they can help you build your own!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].