mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2025-09-04 09:21:25 +03:00
Improvements and fixes, start on command manager
This commit is contained in:
@@ -80,15 +80,13 @@ module.exports = class PluginManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically register and load plugins
|
||||
*/
|
||||
/** Automatically register and load plugins */
|
||||
load() {
|
||||
// normal plugins (NPM)
|
||||
this.client.config.plugins.forEach(plugin => {
|
||||
try {
|
||||
let pkg = require(`${plugin}/package.json`);
|
||||
let main = require(plugin);
|
||||
let pkg = require(`${plugin}/package.json`);
|
||||
this.registerPlugin(true, main, pkg);
|
||||
} catch (e) {
|
||||
this.client.log.warn(`An error occurred whilst loading ${plugin}; have you installed it?`);
|
||||
|
@@ -14,14 +14,13 @@ module.exports = class Plugin {
|
||||
* @param {Object} options Plugin options
|
||||
* @param {String} options.name A human-friendly name (can be different to the name in package.json)
|
||||
*/
|
||||
constructor(client, id, options) {
|
||||
if (typeof options === 'object') {
|
||||
/** The human-friendly name of the plugin */
|
||||
this.name = options.name || id;
|
||||
}
|
||||
constructor(client, id, options = {}) {
|
||||
/** The human-friendly name of the plugin */
|
||||
this.name = options.name || id;
|
||||
|
||||
/** The Discord Client */
|
||||
this.client = client;
|
||||
|
||||
/** The PluginManager */
|
||||
this.manager = this.client.plugins;
|
||||
|
||||
@@ -36,16 +35,21 @@ module.exports = class Plugin {
|
||||
|
||||
/** The unique ID of the plugin (NPM package name) */
|
||||
this.id = id;
|
||||
|
||||
/** The version of the plugin (NPM package version) */
|
||||
this.version = version;
|
||||
|
||||
/** The plugin author's name (NPM package author) */
|
||||
this.author = author;
|
||||
|
||||
/** The plugin description (NPM package description) */
|
||||
this.description = description;
|
||||
|
||||
this.directory = {};
|
||||
|
||||
/** A cleaned version of the plugin's ID suitable for use in the directory name */
|
||||
this.directory.name = this.id.replace(/@[-_a-zA-Z0-9]+\//, '');
|
||||
|
||||
/** The absolute path of the plugin directory */
|
||||
this.directory.path = path(`./user/plugins/${this.directory.name}`);
|
||||
}
|
||||
|
Reference in New Issue
Block a user