FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Xjectro/java-discord-bot: ๐Ÿค– A customizable Discord bot developed with Java. ยท GitHub

/ java-discord-bot Public template

Latest commit

ย 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– 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

๐Ÿšฆ Steps

  1. ๐Ÿ“ฅ Clone the repository:
    git clone https://github.com/Xjectro/java-discord-bot.git
    cd java-discord-bot
    
  2. ๐Ÿ“ฆ Install dependencies and build:
./gradlew build
  1. ๐Ÿ” 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
  2. ๐Ÿš€ Start the bot:

    ./gradlew run

๐Ÿ•น๏ธ Usage

After adding the bot to your server, you can use the following commands:

๐Ÿ‘‘ Auto Role System

  • !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 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.

๐Ÿ“ฌ Contact

๐Ÿš€ 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


Back | FazBrowse Home | New Git URL