Built on Maven with Javacord & dev.kmfg.lavaplayer
- Discord Tokens: Obtain from Discord Developer Portal.
- Spotify Tokens: Obtain from Spotify Developer Dashboard.
- Optional: MariaDB for database functionality.
Please note, you may see errors or warnings in the logs about Hibernate, SQL, or general Database langauge. If you go this route, please ignore them.
- Install Java 11 & Maven:
- MacOS:
brew install openjdk@11 maven
- Debian/Ubuntu:
sudo apt install openjdk-11-jre maven
- MacOS:
- Create a Discord Application here. Note down the bot token.
- Create a Spotify Application here. Record client & secret IDs.
- Clone the repository:
git clone https://github.com/kyleyannelli/KMusicBot && cd KMusicBot
. - Now, go into the
kmusicbot-core
directory, and create a file called .env, like so:
DISCORD_BOT_TOKEN="YOUR_BOT_TOKEN"
SPOTIFY_CLIENT_ID="YOUR_SPOTIFY_CLIENT_ID"
SPOTIFY_SECRET_ID="YOUR_SPOTIFY_SECRET_ID"
# The following are for number of threads for the bot's services.
# If you are unsure about this, leave it as 10 (default)
# If you are CERTAIN this will run in only one server, or you are tight on resources, set each to 1
MAX_RECOMMENDER_THREADS=10
MAX_COMMAND_THREADS=10
- Go to the root directory of the project...
cd ../
- Run the bot:
- With Docker:
./BuildThenRunWithDocker -d
- Without Docker:
mvn clean install && cd kmusicbot-core && mvn exec:java
- Done :)
- Follow steps 1-6 from Without a Database.
- If you already setup the SQL user and know what you're doing, skip to step 13. Install MariaDB (or MySQL). On MacOS,
brew install mariadb
. Debian-based/Ubuntu,sudo apt install mariadb-server
. - Run the command
sudo mysql
. - You are now in the MariaDB/MySQL CLI. You need to create a database and a user. First, the database.
CREATE DATABASE MAKE_YOUR_OWN_NAME_PLEASE;
You now have a database with the name you created! - Now, creating the user. This requires you to be aware of where the database and bot are running from. If they are running on the same machine, we can use localhost. `CREATE USER 'kmusic'@'localhost' IDENTIFIED BY 'very-strong-password-please-dont-use-this;' Make SURE to create a STRONG password.
- From here we need to ensure this kmusic@localhost user can access MAKE_YOUR_OWN_NAME_PLEASE database, and only that database. Do not grant .. `GRANT ALL PRIVILEGES ON MAKE_YOUR_OWN_NAME_PLEASE.* TO 'kmusic'@'localhost' WITH GRANT OPTION;'
- To ensure the changes are in place, finally, run
FLUSH PRIVILEGES;
You can now exit the SQL CLI withexit;
- Now, make sure you are in the kmusicbot-database directory. From there, in
src/main/resources/
, copy thehibernate.cfg.xml.example
tohibernate.cfg.xml
andliquibase.properties.example
toliquibase.properties
- Begin with the hibernate file. Adjust the line with the URL like so,
jdbc:mariadb://localhost:3306/MAKE_YOUR_OWN_NAME_PLEASE
Next, adjust the user and password accordingly. - Moving onto the liquibase file, do the same!
- That was a lot of steps, I know. Your bot will now record user listening activity. You can now continue back from step 7 of Without a Database.
- From the Discord Developer portal, obtain your OAuth credentials (ID & Secret). Write them down.
- Go into the kmusicbot-api, create a file called .env, like so:
DISCORD_CLIENT_ID=""
DISCORD_CLIENT_SECRET=""
# Fully qualified domain name (FQDN), such as music.kmfg.dev. If just running locally, something like http://192.168.1.55.
DISCORD_REDIRECT_URI="https://FQDN/api/callback"
# This encrypts the discord tokens. The reason the API does this is so the discord tokens are useless outside of KMusic API.
# I recommend making this a strong password!
ENCRYPTION_PASS="notSomethingLike1234Please"
# If you are running the API for a Web interface or the like, set the base route of your site's domain!
# You can run into CORS issues here if you put the API on https://api.kyle.city and host the site on https://music.kmfg.dev.
# I would recommend keeping the parent domain the same.
CORS_URI="https://music.kmfg.dev"
# I'd recommend using your parent domain. For example, my api is served on apiv1.kmfg.dev. This means for the cookie to be valid (browser only) and be accessed by svelte on music.kmfg.dev, the URI needs to be the parent.
COOKIE_URI="kmfg.dev"
- Make sure the entire project has been compiled, if not, go to the root directory and
mvn clean install
. Inkmusicbot-api
runmvn exec:java
. Your API is now running!