0.0.6 • Published 6 months ago

discord-modulecontroller v0.0.6

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
6 months ago

Discord ModuleController (Public Alpha Test)

Version: 0.0.3
Status: Alpha Test

Description

ModuleController is an Alpha Test for managing Discord bot modules, allowing you to dynamically load, configure, and manage various parts of your bot's functionality. This is an ongoing test phase, and the API may change.

Features

  • Dynamic module loading and configuration.
  • Supports different types of modules (commands, events, context menus, buttons, etc.).
  • Auto-completion support for module management.

Installation

To install the package, use npm:

npm install discord-modulecontroller

Usage

To initialize the client and load the modules, you can follow this structure:

Example Import necessary modules from discord.js:

const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
    intents: [
        GatewayIntentBits.Guilds,
        GatewayIntentBits.GuildMessages,
        GatewayIntentBits.MessageContent
    ]
});

Example Load the 'discord-modulecontroller' module to handle module management:

const DiscordBotModuleManager = require('discord-modulecontroller');
const path = require('path'); // The path module helps manage file paths

Example Configuration for the modules:

const ModulesConfig = {
    // Main modules directory, where general modules are stored
    modules: {
        name: "Modules", // Name of the modules
        path: path.join(__dirname, './modules') // Path to the modules folder
    },
    // Directory for bot commands
    commands: {
        name: "Commands", // Name for the commands
        path: path.join(__dirname, './events/commands/') // Path to the commands folder
    },
    // Directory for events, where bot events are handled
    events: {
        name: "Events", // Name for the events
        path: path.join(__dirname, './events/') // Path to the events folder
    },
    // Directory for ContextMenus (context menus) modules
    contextmenus: {
        name: "ContextMenus", // Name for the context menus
        path: path.join(__dirname, './events/ContextMenu/') // Path to the context menus folder
    },
    // Directory for AutoCompletes (auto-completion) modules
    autocompletes: {
        name: "AutoCompletes", // Name for auto-completion
        path: path.join(__dirname, './events/autocomplete/') // Path to the auto-completion folder
    },
    // Directory for Buttons, interactive UI elements in Discord
    buttons: {
        name: "Buttons", // Name for buttons
        path: path.join(__dirname, './events/buttons/') // Path to the buttons folder
    },
    // Directory for Modals, pop-up dialog windows in Discord
    modals: {
        name: "Modals", // Name for modals
        path: path.join(__dirname, './events/modals/') // Path to the modals folder
    },
    // Directory for StringSelectMenus (text-based dropdown menus)
    stringselectmenus: {
        name: "StringSelectMenus", // Name for string select menus
        path: path.join(__dirname, './events/StringSelectMenu/') // Path to the string select menus folder
    }
};

Example Initialize the bot using DiscordBotModuleManager and load modules based on the configuration:

DiscordBotModuleManager.ClientInit(client, {}, ModulesConfig);

Full Example Code:

const DiscordBotModuleManager = require('discord-modulecontroller');
const path = require('path');
const ModulesConfig = {
    modules: {
        name: "Modules",
        path: path.join(__dirname, './modules')
    },
    commands: {
        name: "Commands",
        path: path.join(__dirname, './commands/')
    },
    events: {
        name: "Events",
        path: path.join(__dirname, './events/')
    },
    contextmenus: {
        name: "ContextMenus",
        path: path.join(__dirname, './ContextMenu/')
    },
    autocompletes: {
        name: "AutoCompletes",
        path: path.join(__dirname, './autocomplete/')
    },
    buttons: {
        name: "Buttons",
        path: path.join(__dirname, './buttons/')
    },
    modals: {
        name: "Modals",
        path: path.join(__dirname, './modals/')
    },
    stringselectmenus: {
        name: "StringSelectMenus",
        path: path.join(__dirname, './StringSelectMenu/')
    }
};
DiscordBotModuleManager.ClientInit(client, {}, ModulesConfig);

Functions Overview

Here are some of the key functions provided by ModuleController:

  • ClientInit: Initializes the ModuleController and defines module management.
  • getModuleChoices(client): Returns module types (used for AutoComplete).
  • getModulesByType(client, type, keyword): Fetches the list of modules based on the type and keyword for search functionality.
  • getUnloadedModulesByType(client, type, keyword): Fetches the list of unloaded modules based on the type and keyword.
  • getNotLoadedModuleChoices(client): Returns module types for modules that haven't been loaded yet.
  • getModulePath(moduleType, moduleName): Returns the full path of the module based on type and name.
  • ModuleFileLoader(client, moduleType, filePath, {}): Loads the module from the specified path.
  • TEST_unloadModuleFile(client, moduleType, filePath, {}): Unloads the module from the specified path.

Contributing

At the moment, contributing through issues or pull requests is not available. However, this feature will be added in the future.

License

This project is licensed under the terms of the proprietary license. Please see the LICENSE file for more information.

Contact

For any questions or feedback, feel free to contact us at:
Email: support@zrs.hu
Website: https://zrs.hu

0.0.5

6 months ago

0.0.6

6 months ago

0.0.4

6 months ago

0.0.3

6 months ago

0.0.2

7 months ago

0.0.1

7 months ago