mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2025-09-02 08:41:25 +03:00
Make things work
This commit is contained in:
@@ -7,7 +7,6 @@ module.exports = client => {
|
||||
|
||||
for (const file of files) {
|
||||
const listener = require(`../listeners/${file}`);
|
||||
// client.on(listener.event, ...args => listener.execute(client, ...args));
|
||||
client.on(listener.event, args => listener.execute(client, args));
|
||||
client.on(listener.event, (...args) => listener.execute(client, ...args));
|
||||
}
|
||||
};
|
@@ -1,35 +1,14 @@
|
||||
const yarpm = require('yarpm');
|
||||
const fs = require('fs');
|
||||
const { join } = require('path');
|
||||
const { path } = require('../utils/fs');
|
||||
|
||||
module.exports = async client => {
|
||||
const plugins = {};
|
||||
const dirs = fs.readdirSync(path('./user/plugins'));
|
||||
|
||||
for (const dir of dirs) {
|
||||
let package_path = path(`./user/plugins/${dir}/package.json`);
|
||||
if (!fs.existsSync(package_path)) continue;
|
||||
|
||||
let package = require(`../../user/plugins/${dir}/package.json`);
|
||||
let main = require(join(`../../user/plugins/${dir}/`, package.main));
|
||||
|
||||
plugins[package.name] = package;
|
||||
client.log.plugins(`Loading ${package.name} v${package.version} by ${package.author}`);
|
||||
|
||||
if (package.dependencies && Object.keys(package.dependencies).length >= 1) {
|
||||
client.log.plugins(`Installing dependencies for ${package.name}`);
|
||||
let deps = Object.keys(package.dependencies)
|
||||
.map(d => `${d}@${package.dependencies[d]}`)
|
||||
.join(' ');
|
||||
|
||||
await yarpm(['install', '--no-save', deps], {
|
||||
stdout: process.stdout
|
||||
});
|
||||
await main(client);
|
||||
} else {
|
||||
await main(client);
|
||||
client.config.plugins.forEach(plugin => {
|
||||
try {
|
||||
let package = require(`${plugin}/package.json`);
|
||||
client.log.plugins(`Loading ${package.name} v${package.version} by ${package.author?.name || 'unknown'}`);
|
||||
require(plugin)(client);
|
||||
} catch (e) {
|
||||
client.log.warn(`An error occurred whilst loading ${plugin}, have you installed it?`);
|
||||
client.log.error(e);
|
||||
return process.exit();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
};
|
Reference in New Issue
Block a user