Discord.js music

Discord.js music DEFAULT


A complete code to download for a music bot

Looking for a code for a music bot ? This fully open source code is made for your project !

If you need help with this project, to get support faster you can join the help server by just clicking here.

If you don't have any development knowledge, it is recommended to join the Discord support server to get help.


Open the configuration file located in the main folder .

module.exports={app: {px: 'XXX',token: 'XXX',playing: 'by Zerio ❤️'},opt: {DJ: {enabled: false,roleName: 'XXX',commands: []},maxVol: 100,loopMessage: false,discordPlayer: {}}};

Basic configuration

  • , the prefix that will be set to use the bot
  • , the token of the bot available on the Discord Developers section
  • , the activity of the bot

DJ mode configuration

  • , whether the DJ mode should be activated or not
  • , the name of the DJ role to be used
  • , the list of commands limited to members with the DJ role

Advanced configuration

  • , the maximum volume that users can define
  • , if the message that a music is played should be sent when it is looped
  • , options used by discord-player


To use the project correctly you will need some tools.

FFmpeg to process audio

Node JS (v16) for environment

Without forgetting of course the code editor ^^

Realized with by ZerioDev.

Please do not withdraw the license and keep the credits on this project.

To have full access to the project and to be able to withdraw the credits a small donation is accepted.

Sours: https://github.com/ZerioDev/Music-bot

EvoBot (Discord Music Bot)

Node buildDocker buildCommitizen friendly


EvoBot is a Discord Music Bot built with discord.js & uses Command Handler from discordjs.guide


  1. Discord Bot Token Guide
  2. YouTube Data API v3 Key Guide
    2.1 (Optional) Soundcloud Client ID Guide
  3. Node.js v14.0.0 or newer

Getting Started

git clone https://github.com/eritislami/evobot.git cd evobot npm install

After installation finishes follow configuration instructions then run to start the bot.


Copy or Rename to and fill out the values:

Note: Never commit or share your token or api keys publicly


Docker Configuration

For those who would prefer to use our Docker container, you may provide values from as environment variables.

docker run -e "TOKEN=<discord-token>" -e "YOUTUBE_API_KEY=<youtube-key>" eritislami/evobot

Features & Commands

Note: The default prefix is '/'

  • Play music from YouTube via url
  • Play music from YouTube via search query
  • Play music from Soundcloud via url
  • Search and select music to play

Reply with song number or numbers seperated by comma that you wish to play

Examples: or

  • Play youtube playlists via url
  • Play youtube playlists via search query
  • Now Playing (/np)
  • Queue system (/queue, /q)
  • Loop / Repeat (/loop)
  • Shuffle (/shuffle)
  • Volume control (/volume, /v)
  • Lyrics (/lyrics, /ly)
  • Pause (/pause)
  • Resume (/resume, /r)
  • Skip (/skip, /s)
  • Skip to song # in queue (/skipto, /st)
  • Move a song in the queue (/move, /mv)
  • Remove song # from queue (/remove, /rm)
  • Play an mp3 clip (/clip song.mp3) (put the file in sounds folder)
  • List all clips (/clips)
  • Show ping to Discord API (/ping)
  • Show bot uptime (/uptime)
  • Toggle pruning of bot messages (/pruning)
  • Help (/help, /h)
  • Command Handler from discordjs.guide
  • Media Controls via Reactions



Currently available locales are:

  • English (en)
  • Arabic (ar)
  • Brazilian Portuguese (pt_br)
  • Dutch (nl)
  • French (fr)
  • German (de)
  • Greek (el)
  • Indonesian (id)
  • Italian (it)
  • Japanese (ja)
  • Korean (ko)
  • Polish (pl)
  • Russian (ru)
  • Simplified Chinese (zh_cn)
  • Singaporean Mandarin (zh_sg)
  • Spanish (es)
  • Swedish (sv)
  • Traditional Chinese (zh_tw)
  • Thai (th)
  • Turkish (tr)
  • Ukrainian (uk)
  • Vietnamese (vi)
  • Check Contributing if you wish to help add more languages!
  • For languages please use ISO 639-1 two letter format


  1. Fork the repository
  2. Clone your fork:
  3. Create your feature branch:
  4. Stage changes
  5. Commit your changes: OR do not use
  6. Push to the branch:
  7. Submit a pull request


@iCrawl For the queue system used in this application which was adapted from @iCrawl/discord-music-bot

Sours: https://github.com/eritislami/evobot
  1. 28mm exhaust
  2. Log cabin inn near me
  3. Montgomery county mugshots
  4. Duval county teacher
  5. The swagger salon

How to create a music bot using Discord.js

The discord API provides you with an easy tool to create and use your own bots and tools. Today we are going to take a look at how we can create a basic music bot and add it to our server. The bot will be able to play, skip and stop the music and will also support queuing functionality.


Before we get started creating the bot make sure that you have installed all the needed tools.

After the installation, we can continue by setting up our discord bot.

Setting up a discord bot

First, we need to create a new application on the discord development portal.

We can do so by visiting the portal and clicking on new application.

Creating a new application

After that, we need to give our application a name and click the create button.

Creating a discord bot

After that, we need to select the bot tab and click on add bot.

Discord bot information page

Now our bot is created and we can continue with inviting it to our server.

Adding the bot to your server

After creating our bot we can invite it using the OAuth2 URL Generator.

For that, we need to navigate to the OAuth2 page and select bot in the scope tap.

OAuth2 tab

After that, we need to select the needed permissions to play music and read messages.

Giving the discord bot the needed permissions

Then we can copy our generated URL and paste it into our browser.

Discord bot invite link

After pasting it, we add it to our server by selecting the server and clicking the authorize button.

Invite the bot to the server

Creating our project

Now we can start creating our project using our terminal.

First, we create a directory and move into it. We can do so by using these two commands.

After that, we can create our project modules using the npm init command. After entering the command you will be asked some questions just answer them and continue.

Then we just need to create the two files we will work in.

Now we just need to open our project in our text editor. I personally use VS Code and can open it with the following command.

Discord js basics

Now we just need to install some dependencies before we can get started.

After the installation finished we can continue with writing our config.json file. Here we save the token of our bot and the prefix he should listen for.

To get your token you need to visit the discord developer portal again and copy it from the bot section.

Copy token

That are the only things we need to do in our config.json file. So let’s start writing our javascript code.

First, we need to import all our dependencies.

After that, we can create our client and login using our token.

Now let’s add some basic listeners that console.log when they get executed.

After that, we can start our bot using the node command and he should be online on discord and print “Ready!” in the console.

Reading messages

Now that our bot is on our server and able to go online, we can start reading chat messages and responding to them.

To read messages we only need to write one simple function.

Here we create a listener for the message event and get the message and save it into a message object if it is triggered.

Now we need to check if the message is from our own bot and ignore it if it is.

In this line, we check if the author of the message is our bot and return if it is.

After that, we check if the message starts with the prefix we defined earlier and return if it doesn’t.

After that, we can check which command we need to execute. We can do so using some simple if statements.

In this code block, we check which command to execute and call the command. If the input command isn’t valid we write an error message into the chat using the send() function.

Now that we know which command we need to execute we can start implementing these commands.

Adding songs

Let's start by adding the play command. For that, we need a song and a guild (A guild represent an isolated collection of users and channels and is often referred to as a server). We also need the ytdl library we installed earlier.

First, we need to create a map with the name of the queue where we save all the songs we type in the chat.

After that, we create an async function called execute and check if the user is in a voice chat and if the bot has the right permission. If not we write an error message and return.

Now we can continue with getting the song info and saving it into a song object. For that, we use our ytdl library which gets the song information from the youtube link.

This will get the information of the song using the ytdl library we installed earlier. Then we save the information we need into a song object.

After saving the song info we just need to create a contract we can add to our queue. To do so we first need to check if our serverQueue is already defined which means that music is already playing. If so we just need to add the song to our existing serverQueue and send a success message. If not we need to create it and try to join the voice channel and start playing music.

Here we check if the serverQueue is empty and add the song to it if it’s not. Now we just need to create our contract if the serverQueue is null.

In this code block, we create a contract and add our song to the songs array. After that, we try to join the voice chat of the user and call our play() function we will implement after that.

Playing songs

Now that we can add our songs to our queue and create a contract if there isn’t one yet we can start implementing our play functionality.

First, we will create a function called play which takes two parameters (the guild and the song we want to play) and checks if the song is empty. If so we will just leave the voice channel and delete the queue.

After that, we will start playing our song using the play() function of the connection and passing the URL of our song.

Here we create a stream and pass it the URL of our song. We also add two listeners that handle the end and error event.

Note: This is a recursive function which means that it calls itself over and over again. We use recursion so it plays the next song when the song is finished.

Now we are ready to play a song by just typing !play URL in the chat.

Skipping songs

Now we can start implementing the skipping functionality. For that, we just need to end the dispatcher we created in our play() function so it starts the next song.

Here we check if the user that typed the command is in a voice channel and if there is a song to skip.

Stoping songs

The stop() function is almost the same as the skip() except that we clear the songs array which will make our bot delete the queue and leave the voice chat.

Complete source code for the index.js:

Here you can get the complete source code for our music bot:


You made it all the way until the end! Hope that this article helped you understand the Discord API and how you can use it to create a simple bot. If you want to see an example of a more advanced discord bot you can visit my Github repository.

If you have found this useful, please consider recommending and sharing it with other fellow developers.

If you have any questions or feedback, let me know in the comments down below.

Sours: https://gabrieltanner.org/blog/dicord-music-bot
How To Make A Discord Bot - Music Bot Advanced (2021)

Discord Music Bot

Thanks for 25k Views with 500 subs!

✨Latest Updates

Discord.js v13 will break this bot so do not use this with it. We have been started working on v5 which will be out in some days/months with new features and much more are on the way.

🚧 Prerequisites

NOTE: Lavalink is needed for music functionality. You need to have a working Lavalink server to make the bot work.

📝 Tutorial

A Tutorial has been uploaded on YouTube, Watch it by clicking on the image down below

Advanced Discord Music Bot with Web Dashboard | Spotify Support

Repl.it Tutorial

VPS / Server Tutorial

📝 Support Server

If you have major coding issues with this bot, please join and ask for help.

📸 Screenshots

💨 Run the projects

Remix on GlitchDeployRun on Repl.it

Note: If you are hosting your bot in heroku, Please consider upgrading your dyno for running dashboard & bot simultaneously because in free dyno it'll run out of memory(as there are two workers). If you want to run only the bot, turn off the dyno.

✨ Contributors

Contributions are always welcomed :D Make sure to follow Contributing.md

Note: Contributions are not accepted in the master branch. If you like to contribute check out v5 branch

Made with ❤️ and JavaScript!

Sours: https://elements.heroku.com/buttons/SudhanPlayz/Discord-MusicBot

Music discord.js

Issues with music bot using discord.js

I am running into some errors while creating a basic discord bot (for playing music). I've been relying on the documentation mostly - I think I copied and pasted certain lines of code from the discord.js documentation examples that were "out of context". But I don't know what they could be since I'm still very new to programming in general.

I installed and imported all of the necessary dependencies so that's not the issue. My bot is working fine (listening and replying to msgs).

here's the code related to the music function

This is the error I got:

Could it be:

  1. The bot needs to be in a channel first? (which means i need to write a join channel function?)
  2. An issue with the prefix? The defined prefix in my config.json file is i did try changing the prefix to that, removing it completely, and a bunch of other things but nothing seemed to make the bot work.
  3. a syntax error (or something is missing) in the async function ?

asked May 2 at 13:52

Sours: https://stackoverflow.com/questions/67357164/issues-with-music-bot-using-discord-js
How To Make a Custom Discord Command and Music Bot


You will also be interested:


753 754 755 756 757