Integrating Discord Player
Learn how to integrate Discord Player in your Discord bot
Discord Player is a powerful and easy-to-use music framework for Discord.js. It provides a simple and easy-to-use API to play music in your Discord bot. This guide will help you integrate Discord Player in your Discord bot.
Installation
To create a music bot using Discord Player, you need to install discord-player and its dependencies. You can do this by running the following command:
We are also installing @discord-player/extractor
as it contains the default extractors for Discord Player which
provides ability to play audio from local files, raw url or SoundCloud. Discord Player on itself does not support
anything.
Initialization
Discord Player works with both discord.js and Eris. You can initialize Discord Player based on the library you are using.
We don't recommend assigning player
to client
using client.player = player
here. Discord Player provides
hooks (aka helper functions) to access discord-player objects at ease.
That's it! You have successfully initialized Discord Player in your bot.
Even though Discord Player supports Eris, the guide from here will focus on discord.js. You can refer to the Eris documentation for more information on Eris specific APIs. Concept wise, both discord.js and Eris are similar.
In the next section, we will learn about extractors and how to integrate them to support audio streaming.