https://github.com/xjectro/java-discord-bot
đ¤ A customizable Discord bot developed with Java.
https://github.com/xjectro/java-discord-bot
boilerplate bot bots discord discord-api discord-app discord-bot discord-bot-template discord-java discordbot discordjava example gradle java java-8 jda mongodb sharding starter template
Last synced: 11 days ago
JSON representation
đ¤ A customizable Discord bot developed with Java.
- Host: GitHub
- URL: https://github.com/xjectro/java-discord-bot
- Owner: Xjectro
- License: mit
- Created: 2025-06-05T13:02:33.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-06-06T11:22:48.000Z (11 months ago)
- Last Synced: 2025-06-06T12:29:52.235Z (11 months ago)
- Topics: boilerplate, bot, bots, discord, discord-api, discord-app, discord-bot, discord-bot-template, discord-java, discordbot, discordjava, example, gradle, java, java-8, jda, mongodb, sharding, starter, template
- Language: Java
- Homepage: https://xjectro.com
- Size: 54.7 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# đ¤ java-discord-bot
A customizable Discord bot developed with Java.
## ⨠Features
- đ Command-based structure
- ⥠Event listeners
- đ§Š Easily extensible architecture
- đ ī¸ Modern Java and Gradle usage
## âī¸ Installation
### đ Requirements
- â Java 17 or higher
- đ ī¸ [Gradle](https://gradle.org/) (or local setup with `gradlew`)
- đ A Discord bot token ([Discord Developer Portal](https://discord.com/developers/applications))
### đĻ Steps
1. đĨ Clone the repository:
```sh
git clone https://github.com/Xjectro/java-discord-bot.git
cd java-discord-bot
2. đĻ Install dependencies and build:
```sh
./gradlew build
```
3. đ Add your bot token and (optionally) database connection string to the `app/.env` file. Example:
```env
DISCORD_TOKEN=YOUR_DISCORD_BOT_TOKEN
MONGO_URI=mongodb://localhost:27017
```
4. đ Start the bot:
```sh
./gradlew run
```
## đšī¸ Usage
After adding the bot to your server, you can use the following commands:
### đ Auto Role System
* `!autorole [@role1 @role2 ...]`
* đ Enables or disables the auto role system and sets the roles to assign.
* đĄ Example: `!autorole enabled @Member @Registered`
* Slash command version:
* `/autorole status: roles:@role1,@role2,...`
* đĄ Example: `/autorole status:enabled roles:@Member,@Registered`
> â ī¸ You need the **Manage Roles** permission to use these commands.
### đ Ping Command
* `!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.
## đ¤ Contributing
Contributions are welcome! Please open an issue before submitting a pull request.
## đ License
This project is licensed under the [MIT License](LICENSE).
## đŦ Contact
* đ¤ Developer: [Xjectro](https://github.com/Xjectro)
* đ¤ Developer2: [range79](https://github.com/range79)
* đ Project Link: [github.com/Xjectro/java-discord-bot](https://github.com/Xjectro/java-discord-bot)
## đ 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.
### đī¸ Architecture
* đ **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
### đĻ Main Libraries Used
* [đ¤ JDA](https://github.com/DV8FromTheWorld/JDA)
* [đĸ Morphia](https://morphia.dev/)
* [đī¸ dotenv-java](https://github.com/cdimascio/dotenv-java)
* [đ MongoDB Java Driver](https://mongodb.github.io/mongo-java-driver/)