-
-
Notifications
You must be signed in to change notification settings - Fork 90
Setup project locally
This tutorial shows how to download, setup and start the TJ-Bot project locally on your machine.
Alternatively, you can also work directly in the cloud, for free, and get started in just a few seconds. See:
- Java 21 installed
- your favorite Java IDE or text editor, e.g. IntelliJ or Eclipse
-
git
installed (or any GUI or IDE plugin) -
gradle
available (or any GUI or IDE plugin), you can either install it or use our provided wrapper - your own Discord-Bot, tied to a server (see Create Discord server and bot)
- a token of that bot
- use git to download the project
- use gradle to download dependencies
- use gradle to build the project
- connect your bot to the program
- use gradle to start the bot
- interact with the bot from your server
First of all, you have to download the project to your machine. Visit the projects GitHub website and copy the .git
link, which is this
https://github.com/Together-Java/TJ-Bot.git
IntelliJ comes by default with a git
plugin. You can easily clone repositories to your disk by clicking a few buttons.
- open your IntelliJ and select
Get from VCS
. - select
Git
, enter the.git
link and select a directory for the project; smack thatClone
button - IntelliJ will now open the project
To download the project, use the following command:
git clone https://github.com/Together-Java/TJ-Bot.git TJ-Bot
You now have the project and all its data locally.
Next up, you have to download all the dependencies, generate the database and build the project.
IntelliJ comes by default with a gradle
plugin. If not started already automatically, you can command it to do all of above by clicking a bunch of buttons.
- open the Gradle view
- expand the view and click on
TJ-Bot > Tasks > build > build
, or just click on the elephant icon and entergradle build
ℹ️ If you get any gradle errors...
Make sure that your project and gradle is setup to use the latest Java version. Sometimes IntelliJ might guess it wrong and mess up, leading to nasty issues.Therefore, review your Project Structure settings and the Gradle settings:
You can also just execute Gradle from the command line.
- open a command line in the root directory of the project
- execute
gradle build
Last but not least, you want to start the bot with your bot token and let it connect to your private bot with which you can interact from one of your servers.
For this step, you need to hold your bot token ready, you can find it at the Discord Developer Portal.
See the following guide if you still have to create a server and a bot first:
To run the bot, you will need a config.json
file with specific content. You can find a template for this file, with meaningful default values, in application/config.json.template
.
Replace <your_token_here>
with your bot token; you can also adjust the other settings if you want.
- put the configuration file to
TJ-Bot\application\config.json
or run the program with a single argument, the path to your config file - in the Gradle view, click the
run
task and start it
- build a runnable jar of the project by executing
gradle shadowJar
1.1. the jar can now be found atTJ-Bot\application\build\libs
- unless you move the jar around, you have to adjust the database path in the config to
../../../build/database.db
- put the configuration file right next to the jar or run the program with a single argument, the path to your config file
- run
java -jar TJ-Bot.jar
The bot is now running and connected to your server, hurray 🎉
You can now execute commands and see the bot do its magic: