Async TI4 Game Management Discord Bot
Hello Async TI Developers!
This repository is for the AsyncTI4 Game Management Bot which is written in Java using the Discord JDA library to interface with Discord. The AsyncTI4 Game Management Bot is what handles the slash commands, buttons, map images, server management automation, etc.
To get started with development, please read the following:
No good first issue or help wanted issues are currently available.
Get in touch with us at the TI4-Async discord and let us know you'd like the developer role. Branch permissions can be granted, but for now you may fork the repository and clone it to a suitable location.
bot-log channel, and Admin, Developer and Bothelper roles; add the role IDs to src/main/java/ti4/spring/jda/JdaService.javaSee below for methods and examples of how to set up a test bot and server. If you have a different way, please share it here!
Download the latest JDK: https://adoptium.net/
Setup vscode with the default extensions for java: https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack
ctrl+shift+p: Java: Configure Java Runtime -> JavaSE-26
Create a discord server for testing Create a discord application: https://discord.com/developers/applications For the bot settings, go to "Guild Install" scopes -> bot For permissions, select "Administrator"
Go to installation -> copy install link and open in your browser Add the bot to your server
The bot stores data in PostgreSQL. With Docker Desktop running, start a local database from the project root:
docker compose -f docker-compose.local.yml up -d
This matches the defaults in src/main/resources/config/application.yml (localhost:5432, database and user tibot, no password), so no extra environment variables are needed. Tables are created automatically the first time the bot starts. If port 5432 is already taken, set POSTGRES_PORT=5433 before starting and point the bot at it with POSTGRES_JDBC_URL=jdbc:postgresql://localhost:5433/tibot.
To query it: docker exec -it tibot-postgres psql -U tibot -d tibot. To stop it: docker compose -f docker-compose.local.yml down (add -v to delete the data too).
The first time you attempt to Run/Debug in VSCode, it will ask you if you want it to create a launch configuration. Say yes, it should appear in the .vscode folder. Within the configurations section, add the "args" and "env" sections shown below. For VSCode, the file should look very similar to this:
{
"configurations": [
{
"type": "java",
"name": "AsyncTI4DiscordBot",
"request": "launch",
"mainClass": "ti4.AsyncTI4DiscordBot",
"projectName": "TI4_map_generator_discord_bot",
////----vvvvvv COPY THIS INTO YOUR LAUNCH.JSON
"args": [
"{DISCORD_BOT_TOKEN}", // Discord Developer Portal -> Applications -> Bot -> Token
"{DISCORD USER ID}", // Discord User Settings -> Click 3-dot menu next to username -> "Copy USER ID"
"{DISCORD SERVER ID}" // Right-Click Discord Server Name -> "Copy Server ID"
],
"env": {
"DB_PATH": "${workspaceFolder}/storage", // Like: "C:/user/repos/TI4_map_generator_bot/storage" - you may need to create this folder
"RESOURCE_PATH": "${workspaceFolder}/src/main/resources" // Like: "C:/user/repos/TI4_map_generator_bot/src/main/resources"
}
////----^^^^^^ COPY THIS INTO YOUR LAUNCH.JSON
}
]
}
For vscode, this is in .vscode/launch.json.
Set the 5 {VARIABLES} to match your Discord App/Bot's Token, UserID, ServerID, and system.
The bot won't build successfully unless the code is well formatted. We use the Spotless plugin for Maven to enforce this at compile time.
You can run mvn spotless:apply to check for and apply the formatting.
It is highly recommended to install the pre push git hook with mvn spotless:install-git-pre-push-hook, which will run mvn spotless:apply when you try to push, and either successfully push, or fail the push but leave you with formatting changes to commit.
You may want to get "format on save" set up using Spotless, which you can do with plugins.
For Windows/VSCode, you can use the RunOnSave plugin. To run mvn spotless:apply every time you save a .java file, add the following to your VSCode workspace settings:
"settings": {
// "existingSettings": "here",
"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\.java$",
"cmd": "echo File Saved: '${relativeFile}' - Running mvn spotless:apply && mvn spot