From 67a87eac6a927a230f8d51667a27760edc35d2a6 Mon Sep 17 00:00:00 2001 From: Relism Date: Fri, 22 Nov 2024 17:03:43 +0100 Subject: [PATCH] Updated README to reflect changes as of https://github.com/sieadev/MoBot/commit/befe1448b9725a5e65bb27a81a7316cfc1c3b913 --- .gitignore | 1 + README.md | 188 ++++++++++++++++++++++++----------------------------- 2 files changed, 86 insertions(+), 103 deletions(-) diff --git a/.gitignore b/.gitignore index a91c35d..e6e4bd0 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,4 @@ build/ ### Mac OS ### .DS_Store /.idea/ +/modules/ diff --git a/README.md b/README.md index 47e1496..04139ad 100644 --- a/README.md +++ b/README.md @@ -8,124 +8,106 @@ ## Overview +MoBot is a modular bot framework for Discord. It allows developers to create, extend, and manage custom modules that hook into the bot to add rich, interactive features. -MoBot is a modular, extensible bot framework designed for Discord. -With MoBot, developers can create and manage custom modules that hook into MoBot, -allowing for rich, interactive features to be added seamlessly. -Each module is loaded independently and can contain its own configuration, making it easy to extend and customize. +--- -## Table of Contents -- [Roadmap](#roadmap) -- [Features](#features) +
+📋 Table of Contents + +- [Setup Project](#setup-project) - [Installation](#installation) -[Usage](#usage) - - [Getting Started](#getting-started) - - [Creating a Module](#creating-a-module) - - [Module Configuration](#module-configuration) - - [Loading and Managing Modules](#loading-and-managing-modules) -- [Module Development](#module-development) - - [Creating a Module](#creating-a-module) - - [Module Configuration](#module-configuration) - - [Loading and Managing Modules](#loading-and-managing-modules) +- [Creating a Module](#creating-a-module) +- [Module Configuration](#module-configuration) +- [Loading and Managing Modules](#loading-and-managing-modules) - [License](#license) -## Roadmap -- [x] Modules - - [x] Load modules - - [x] Load module information from `module.yml` - - [x] Execute `preEnable`, `onEnable`, `onDisable` and `postDisable` - - [x] Account for priority when enabling -- [ ] Convenient Addons - - [x] Slash Command Addon - - [ ] ???? -- [x] Module Configs - +
-## Features +--- -- **Modular Architecture:** Create and load custom modules easily. -- **Discord Integration:** Built-in support for Discord features like slash commands and event listeners. -- -- **Flexible Configuration:** Each module can have its own `config.yml`, stored in a structured directory. -- **Logging:** Centralized logging for each module, making it easy to debug and monitor activity. -- **Error Reporting:** Identify which module errors are coming from, with detailed logging. +## Setup Project +To create a module for MoBot, follow these steps: -## Module Development +1. **Create a Java Project** (Maven/Gradle): + - **Maven:** + Add the MoBot dependency in `pom.xml`: -### Creating a Module + ```xml + + net.vitacraft + MoBot + VERSION + + ``` -To create a module for MoBot, you need to extend the `MBModule` class. Below is an example of a simple module that logs a message when it is enabled and disabled. + - **Gradle:** + Add the dependency in `build.gradle`: -First, add the MoBot dependency to your `pom.xml`: + ```gradle + dependencies { + implementation "net.vitacraft:MoBot:VERSION" // Replace VERSION + } + ``` -```xml - - pixel-services-releases - Pixel Services - https://maven.pixel-services.com/releases - + Find the latest version [here](https://maven.pixel-services.com/#/releases/net/vitacraft/MoBot). - - net.vitacraft - MoBot - VERSION - -``` +2. **Create Main Module Class**: Extend the `MBModule` class: -Next, create a new class that extends `MBModule`. Here is an example: + ```java + public class WelcomeModule extends MBModule { + @Override + public void onEnable() { + getLogger().info("WelcomeModule enabled!"); + } -```java -public class WelcomeModule extends MBModule { - @Override - public void onEnable() { - // Log a message when the module is enabled - getLogger().info("WelcomeModule enabled!"); + @Override + public void onDisable() { + getLogger().info("WelcomeModule disabled!"); + } } + ``` - @Override - public void onDisable() { - // Log a message when the module is disabled - getLogger().info("WelcomeModule disabled!"); - } -} -``` - -Last but not least your bot needs a `bot.yml` file in your `resources` directory with information about the bot: - -```yaml -name: WelcomeModule -version: '${project.version}' -description: A Test Module -dependencies: [ANOTHER_MODULE] -authors: [sieadev] -priority: DEFAULT -``` - -### Module Configuration - -Each module can have its own configuration file. You can load the configuration using the `getConfigLoader` method. If no file name is passed, it defaults to `config.yml`. Here is an example: - -```java -@Override -public void onEnable() { - // Load the default configuration (config.yml) - ConfigLoader config = getConfigLoader(); - // Log a message when the module is enabled - getLogger().info("Hello World!"); -} -``` - -### Loading and Managing Modules - -Modules are loaded and managed by MoBot. You can use the `getModuleInfo` method to get information about the module, such as its name and version. Here is an example: - -```java -@Override -public void onEnable() { - // Get module information - ModuleInfo info = getModuleInfo(); - // Log the module name and version - getLogger().info("Hey from: module - " + info.getName() + " v" + info.getVersion()); -} -``` \ No newline at end of file +3. **Create Service File**: Create `resources/META-INF/services/net.vitacraft.api.MBModule`, and to this file add **one line** to it: the fully qualified name of your main module class, for example: + + ```text + com.example.WelcomeModule + ``` + +--- + +## Installation + +1. **Install MoBot** by adding it as a dependency in your Maven or Gradle project (see the Setup Project section). + +2. **Create `bot.yml`** file inside the `resources` folder to configure your bot: + + ```yaml + name: WelcomeModule + version: '1.0.0' + description: A Test Module + dependencies: [] + authors: [Your Name] + priority: DEFAULT + ``` + +--- + +## Creating a Module + +1. **Extend `MBModule`**: + In your Java class, override `onEnable()` and `onDisable()`: + + ```java + public class WelcomeModule extends MBModule { + @Override + public void onEnable() { + getLogger().info("Module enabled!"); + } + + @Override + public void onDisable() { + getLogger().info("Module disabled!"); + } + }