A customizable Discord bot developed with Java.
- π Command-based structure
- β‘ Event listeners
- π§© Easily extensible architecture
- π οΈ Modern Java and Gradle usage
- β Java 17 or higher
- π οΈ Gradle (or local setup with
gradlew) - π A Discord bot token (Discord Developer Portal)
- π₯ Clone the repository:
git clone https://github.com/Xjectro/java-discord-bot.git cd java-discord-bot - π¦ Install dependencies and build:
./gradlew build-
π Add your bot token and (optionally) database connection string to the
app/.envfile. Example:DISCORD_TOKEN=YOUR_DISCORD_BOT_TOKEN MONGO_URI=mongodb://localhost:27017
-
π Start the bot:
./gradlew run
After adding the bot to your server, you can use the following commands:
-
!autorole <enabled|disabled> [@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:<enabled|disabled> roles:@role1,@role2,...- π‘ Example:
/autorole status:enabled roles:@Member,@Registered
β οΈ You need the Manage Roles permission to use these commands.
!pingβ Checks if the bot is running.
- ποΈ 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.
- π€ Developer: Xjectro
- π€ Developer2: range79
- π Project Link: github.com/Xjectro/java-discord-bot
- β 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
.envfiles.
- π Command System: All commands are in the
org.example.commandspackage, 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 inapp/.env.
Server-specific auto role settings are stored in MongoDB as follows:
- π Server ID
- π Auto role enabled/disabled status
- π·οΈ IDs of roles to assign