mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2025-09-02 00:31:27 +03:00
Make things work
This commit is contained in:
20
src/index.js
20
src/index.js
@@ -60,21 +60,6 @@ const log = new Logger({
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
log.report = error => {
|
||||
let report = [
|
||||
'<< Issue report >>',
|
||||
'Please include this information if you ask for help about the following error!',
|
||||
`Support server: ${terminalLink('go.eartharoid.me/discord', 'https://go.eartharoid.me/discord')}`,
|
||||
`Node.JS version: ${process.versions.node}`,
|
||||
`Bot version: ${version}`,
|
||||
`Platform: ${process.platform}`
|
||||
];
|
||||
log.warn(report.join('\n'));
|
||||
if (error) log.error(error);
|
||||
};
|
||||
|
||||
const terminalLink = require('terminal-link');
|
||||
const I18n = require('@eartharoid/i18n');
|
||||
const { CommandManager } = require('./modules/commands');
|
||||
|
||||
@@ -109,7 +94,7 @@ class Bot extends Client {
|
||||
this.plugins = await require('./modules/plugins')(this);
|
||||
|
||||
this.log.info('Connecting to Discord API');
|
||||
|
||||
|
||||
this.login();
|
||||
})();
|
||||
}
|
||||
@@ -119,7 +104,8 @@ class Bot extends Client {
|
||||
new Bot();
|
||||
|
||||
process.on('unhandledRejection', error => {
|
||||
log.report();
|
||||
log.notice('PLEASE INCLUDE THIS INFORMATION:');
|
||||
log.warn(`Discord Tickets v${version}, Node ${process.versions.node} (${process.platform})`);
|
||||
log.warn('An error was not caught');
|
||||
if (error instanceof Error) log.warn(`Uncaught ${error.name}: ${error}`);
|
||||
log.error(error);
|
||||
|
@@ -1,8 +1,5 @@
|
||||
module.exports = {
|
||||
event: 'messageReactionAdd',
|
||||
execute: (client, r, u) => {
|
||||
client.log.info('messageReactionAdd');
|
||||
console.log(r);
|
||||
console.log(u);
|
||||
}
|
||||
};
|
@@ -1,6 +1,6 @@
|
||||
module.exports = {
|
||||
event: 'ready',
|
||||
execute: client => {
|
||||
client.log.success(`Connected to Discord as ${client.user.tag}`);
|
||||
execute: (client) => {
|
||||
client.log.success(`Connected to Discord as "${client.user.tag}"`);
|
||||
}
|
||||
};
|
@@ -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