A discord.js v14 music bot that uses Typescript, Node.js, MongoDB. Support deploying in Heroku.
- Support tranditional prefix command (default:
$
) or slash command. - Command aliases.
- Multilanguage (Feel free to contribute and add more languages!).
- Support YouTube single video and playlist (and YouTube music).
- Automatically rejoin the voice channel when the bot has restarted (so the bot can stay in the voice channel 24/7).
- Automatically pause / unpause when there is no one in the voice channel / someone joins the voice channel.
- Playlist system: You can switch between playlists easily.
- Playing now message with progress bar.
- Queue system: See which song is coming next!
- Ranking system: Compete with your friends to see who can stay in the voice channel the longest!
- Help command: Help you understand more about each command.
* Aliases only work on prefix command. It does not work on slash command.
Command | Aliases | Description |
---|---|---|
help |
/ | Provide information on other commands. |
language |
lang |
Show / Change language. |
ping |
/ | Reply with pong! |
prefix |
pre |
Show / Change prefix. |
rank |
ranking |
Show some ranking within the guild. |
stayRank / rank stay |
/ | Show the ranking of voice channel stay duration. |
Command | Aliases | Description |
---|---|---|
createPlaylist / playlist create |
addplaylist |
Create a new playlist. |
infoPlaylist / playlist info |
/ | Show the info of a playlist. |
listPlaylist / playlist list |
listplaylists / showplaylist |
List all the playlists. |
removePlaylist / playlist remove |
deleteplaylist |
Remove a playlist. |
switchPlaylist / playlist switch |
/ | Switch to another playlist. |
playlist |
/ | Remove / Create / Show / Switch to / List / playlist. |
join |
/ | Join your voice channel. |
leave |
/ | Leave your voice channel. |
pause |
stop |
Pause the current song. |
play |
/ | Play the song of the provided YouTube URL. |
prev |
previous |
Play the previous song. |
queue |
/ | Show the queue of the current playlist. |
queueRank / rank queue |
/ | Show the ranking of the number of times played of each song in the current queue. |
remove |
delete |
Remove a song from the list. |
retry |
replay |
Try to play the first song again. Useful when there was error playing the song before. |
search |
/ | Search songs from your queue. |
shuffle |
/ | Shuffle the current queue. |
skip |
/ | Skip the current song. |
unpause |
resume |
Unpause the current song. |
Put these value in .env
file.
Environmental Variable | Required? | Description |
---|---|---|
BOT_TOKEN |
Yes | Can be found in developer portal (Bot -> TOKEN ). |
CLIENT_ID |
Yes | Can be found in developer portal (OAuth2 -> General -> CLIENT ID ). |
GUILD_ID |
No | Used in register-guild-commands , clear-guild-commands , import-songs scripts. |
MONGODB_URL |
Yes | The URL of your MongoDB database (more detail below). Please remove everything after the last / , including the / . For example: For mongodb+srv://<username>:<password>@cluster0.9mmia.mongodb.net/<database_name>?retryWrites=true&w=majority , remove /<database_name>?retryWrites=true&w=majority (i.e.: mongodb+srv://<username>:<password>@cluster0.9mmia.mongodb.net ) |
ENV |
Yes | Can be dev , prod , or debug . If you do not know what this is, just choose prod . |
YOUTUBE_COOKIE |
No | If you encounter Sign in to confirm you’re not a bot , you will need fill in this variabel. See Toubleshooting. |
- Register a MongoDB Altas account.
- Create a cluster.
- On
Databases
tab, clickBrowse Collections
.
- Click
Add My Own Data
. - Create a database named
smoothie
.
- 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
Drivers
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 entered (e.g.user1
). - Please remove everything after the last
/
, including the/
. For example: Formongodb+srv://<username>:<password>@cluster0.9mmia.mongodb.net/<database_name>?retryWrites=true&w=majority
, remove/<database_name>?retryWrites=true&w=majority
(i.e.:mongodb+srv://<username>:<password>@cluster0.9mmia.mongodb.net
). - The URL will be the value of the environment variable
MONGODB_URL
!
* As of today, the free dynos of Heroku is no longer available. However, if you are a student and joined Github Education, you can apply for Heroku for Students to host the bot for free.
- Fork this repository.
- Register an account in Heroku.
- Create a new app.
- Go to
Deploy
tap. Click Github as your deployment method. - Link your Github account to Heroku.
- Choose the repository that you forked. Choose the
main
branch. - Enable automatic deploy.
- Wait for the deploy to finish.
- 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 (SeeEnvironment Variable
section from above). - On right hand corner, click
More
and then clickRun console
. - In the console, type
npm run register-global-commands
to register slash commands globally. - 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!
- If you face
Sign in to confirm you’re not a bot
error, you need provide a YouTube cookie.
Warning
It is strongly suggested that you create a new account to do this instead of using your personal account.
-
Open a random YouTube video with your new account.
-
Open developer tools (
Option + ⌘ + J
(on macOS), orShift + CTRL + J
(on Windows/Linux)). -
Open Network tab.
-
Reload the page. Find and open the first request (which is HTTP GET Request of the webpage).
-
Scroll down and find Request Headers. Find
Cookie
attribute. -
Copy its value to
.env
file. Wrap your cookie with double quotation marks. (e.g.YOUTUBE_COOKIE="<your cookie here>"
).
Warning
Do not logout your YouTube account as it would expire your cookie. Alternatively, you can delete the cookie.
All pull requests are welcome.
Please follow the fork-and-pull
Git workflow.
If you want to contribute to translation, you can take src/i18n/en-US.ts as a reference.
Smoothie is licensed under the GNU General Public License v3.0.