A customizable Discord bot developed with Java.
- ๐ Command-based structure
- โก Event listeners
- ๐งฉ Easily extensible architecture
- ๐ ๏ธ Modern Java and Gradle usage
- ๐ฅ Clone the repository:
git clone https://github.com/Xjectro/java-discord-bot.git
cd java-discord-bot
- ๐ฆ Install dependencies and build:
-
๐ Add your bot token and (optionally) database connection string to the app/.env file. Example:
DISCORD_TOKEN=YOUR_DISCORD_BOT_TOKEN
MONGO_URI=mongodb://localhost:27017
-
๐ Start the bot:
After adding the bot to your server, you can use the following commands:
โ ๏ธ You need the Manage Roles permission to use these commands.
- !ping โ Checks if the bot is running.
๐ ๏ธ Add Your Own Commands
- ๐๏ธ To add new commands, create a new class in the
app/src/main/java/org/example/commands/ directory.
Contributions are welcome! Please open an issue before submitting a pull request.
This project is licensed under the MIT License.
๐ Architecture & Technologies Used
- โ Java 17+: Main programming language.
- ๐ ๏ธ Gradle: Build and project management tool.
- ๐ค JDA (Java Discord API): Core library for Discord bot functionality.
- ๐ MongoDB: NoSQL database for storing server-specific settings and data.
- ๐ข Morphia: ORM library for easy data access between Java and MongoDB.
- ๐๏ธ dotenv-java: Loads environment variables from .env files.
- ๐ Command System: All commands are in the org.example.commands package, making it easy to add new ones.
- โก Event System: Handles Discord events under org.example.events.
- ๐๏ธ Database Management: MongoDB connection and models are under org.example.database.
Server-specific settings (e.g., auto role) are stored in MongoDB.
- โ๏ธ Configuration: Database settings are in
app/src/main/resources/META-INF/morphia-config.properties,
and the connection string is in app/.env.
๐๏ธ Example Database Model
Server-specific auto role settings are stored in MongoDB as follows:
- ๐ Server ID
- ๐ Auto role enabled/disabled status
- ๐ท๏ธ IDs of roles to assign