Version: 0.0.7 Status: Alpha Test
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.
- Dynamic module loading and configuration.
- Supports different types of modules (commands, events, contextmenus, buttons, etc.).
- Auto-completion support for module management.
To install the package, use npm:
npm install discord-modulecontroller
To initialize the client and load the modules, you can follow this structure:
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]
});
const DiscordBotModuleManager = require('discord-modulecontroller');
const path = require('path'); // The path module helps manage file paths
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, '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, 'ContextMenu') // Path to the context menus folder
},
// Directory for AutoCompletes (auto-completion) modules
autocompletes: {
name: "AutoCompletes", // Name for auto-completion
path: path.join(__dirname, '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, '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, 'modals') // Path to the modals folder
},
rest: {
name: "rest",
path: path.join(__dirname, 'rest')
},
// Directory for StringSelectMenus (text-based dropdown menus)
stringselectmenus: {
name: "StringSelectMenus", // Name for string select menus
path: path.join(__dirname, '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);
const path = require('path');
const DiscordBotModuleManager = require('discord-modulecontroller');
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')
},
rest: {
name: "rest",
path: path.join(__dirname, 'rest')
},
stringselectmenus: {
name: "StringSelectMenus",
path: path.join(__dirname, 'StringSelectMenu')
}
};
DiscordBotModuleManager.ClientInit(client, ModulesConfig);
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.
At the moment, contributing through issues or pull requests is not available. However, this feature will be added in the future.
If the LANGUAGE
or language
variable is defined in the .env
file, the plugin will log messages in the specified language.
- English
- Hungarian
Apache-2.0
For any questions or feedback, feel free to contact us at:
Email: support@zrs.hu
Website: https://zrs.hu