⚠️ This repository is no longer maintained. The rewritten version of this bot is here ⚠️
A discord music bot that uses discord.js v13 to program. Support both Spotify and Youtube. Only suitable for a guild with a small group of friends.
Give a 💓 and ⭐ if this bot helps!
- Auto rejoin the voice channel when there is a server update / server crashes (Heroku will restart the server every 24 hours).
- Auto pause and unpause when there is no one in the voice channel / someone joins the voice channel.
- Support both slash command and prefix command! (default:
$
). - Support both Spotify and Youtube!
Command | Description |
---|---|
help | Show all the commands and its description. |
clear | Clear the queue except the music that is currently playing. |
remove | Remove one specific music from the queue. |
join | Join your voice channel. If there is something in the queue, the music will be automatically played. |
leave | Leave your voice channel. |
play | Queue the music with the provided Youtube / Spotify URL. Can either be a single music or a playlist URL. If play_now is True and the URL is an music, the music will play immediately. play_now has no effect on playlist. |
playloopplaylist | Queue the playlist where the URL is specified on environment variable LOOPPLAYLISTURL . The purpose of this command is to avoid copying and pasting the playlist URL where you and your friends save your favourite music on. |
queue | Show the queue. |
shuffle | Shuffle the queue. |
skip | Skip the current music. |
lyrics | Attempt to get the lyrics of the currently-playing song from Genius (may takes some time to load). |
description | Get the Youtube description of the currently-playing music. |
prefix | Change / Show the prefix of your guild (Default: $ ). |
-
Clone the source code.
-
Install all the required dependancies and other stuff (e.g. Node.js >=16.6.0) (
npm install
). -
Create a new bot in discord develop portal.
-
In
configs.json
file, change the value ofuseMongoDB
tofalse
if you not going to use MongoDB. (In Heroku, you need to setup mongoDB in order to permenantly store the data (e.g. queue list, auto rejoin when Heroku restarts). Otherwise the data will be wiped every 24 hours). -
Add a
.env
file at the root folder which stores your environment variables' value.Variable Description CLIENTID
(required)The clientid which can be found on discord develop portal. TOKEN
(required)The bot token which can be found on discord develop portal. DEVUSERIDS
The list of user ids that can use dev commands. Separate with space. (e.g.: "158940399584059687 695485693485676567" without the "") LOOPPLAYLISTURL
The URL of a playlist which you want to play via /playloopplaylist
.LOOPPLAYLISTGUILDIDS
The list of guild ids that can use the command /playloopplaylist
. Separate with space. (e.g.: "158940399584059687 695485693485676567" without the "")MONGODBURL
(required ifuseMongoDB
is true inconfigs.json
)The URL of MongoDB that links to your database (More detail below). If you not gonna use it, you can leave it blank. -
Run
npm start
. The bot should up in running right now!
Remark: Since Heroku filesystem is ephemeral (any changes to the filesystem whilst the dyno is running only last until that dyno is shut down or restarted) and the dyno will restart every 24 hours for free dyno, setting up MongoDB is recommanded so the queue can be saved and auto reconnect will work properly.
If you wanna save the data premenently register a MongoDB Altas account first. Skip this part if you don't care about saving the data.
- Register a MongoDB Altas account.
- Create a cluster.
- On
Databases
tab, clickBrowse Collections
.
- Click
Add My Own Data
. - Create a database named
smoothie
and collection named withguilds
.
- On the left, click
Database Access
. Then clickADD NEW DATABASE USER
. - Click
Password
asAuthentication Method
and type inuser
(e.g.user1
) and password (e.g.user1234
) (Use more secure password!). ClickRead and write to any database
inBuild-in Role
and finally clickAdd User
. - On the left, click
Network Access
. Then clickADD IP ADDRESS
. - Type in
0.0.0.0/0
inAccess List Entry
andAll
inComment
and clickConfirm
. This will enable Heroku to access your database. (0.0.0.0/0
will able all IP to access you database). - Go to
Databases
page and clickConnect
in your cluster tab.
- Click
Connect your application
. - Choose the
DRIVER
asNode.js
andVERSION
as4.0 or later
. - Copy the URL in step 2.
- Replace
<password>
with the password you just entered (e.g.user1234
) and replace<username>
with the user you just eneter (e.g.user1
). ReplacemyFirstDatabase
with the name of the database (i.e.smoothie
if you are following the guide). - The URL will be the value of the environment variable
MONGODBURL
! - Now you can setup Heroku!
- Push the code to your private repository on Github. Do not push the
.env
for security reason. - Register an account in Heroku.
- Create a new app.
- Click Github as your deployment method.
- Link your Github account to Heroku.
- Choose the repository that you just pushed to Github. Wait for the word "the app was successfully deployed".
- Go to
Resources
tab. InFree Dynos
section, disableweb
and turn onWorker
. - Go to
Settings
tab. ClickReveal Config Vars
. Put all the environment variables and its values here. If you do not need MongoDB, you can ignore theMONGODBURL
. - On right hand corner, click
More
and then clickRestart all dynos
. - Click
More
once again and clickView logs
. You should see the bot has been successfully hosted! Congratulations!
- Add alias to commands.
- Add swap, pause, resume commands.
- Add stat command.
- Add spotify support.
- Sometimes you playing now message will pop twice when the first music is played.