Make things work

This commit is contained in:
Isaac 2021-02-16 23:35:31 +00:00
parent 5fdfb121c7
commit 4c8e9125e5
No known key found for this signature in database
GPG Key ID: 279D1F53391CED07
8 changed files with 39 additions and 77 deletions

View File

@ -29,6 +29,7 @@
"funding": "https://github.com/eartharoid/DiscordTickets/?sponsor=1",
"dependencies": {
"@eartharoid/i18n": "^0.0.1",
"command-exists": "^1.2.9",
"discord.js": "^12.5.1",
"dotenv": "^8.2.0",
"keyv": "^4.0.3",
@ -36,8 +37,7 @@
"leekslazylogger": "^2.0.7",
"node-fetch": "^2.6.1",
"sequelize": "^6.5.0",
"terminal-link": "^2.1.1",
"yarpm": "^1.1.1"
"terminal-link": "^2.1.1"
},
"devDependencies": {
"eslint": "^7.20.0",

View File

@ -1,5 +1,6 @@
dependencies:
'@eartharoid/i18n': 0.0.1
command-exists: 1.2.9
discord.js: 12.5.1
dotenv: 8.2.0
keyv: 4.0.3
@ -8,7 +9,6 @@ dependencies:
node-fetch: 2.6.1
sequelize: 6.5.0_fb66e8c649bde1be622cc06164c9e22d
terminal-link: 2.1.1
yarpm: 1.1.1
devDependencies:
eslint: 7.20.0
mariadb: 2.5.2
@ -611,6 +611,7 @@ packages:
path-key: 3.1.1
shebang-command: 2.0.0
which: 2.0.2
dev: true
engines:
node: '>= 8'
resolution:
@ -1902,6 +1903,7 @@ packages:
resolution:
integrity: sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
/path-key/3.1.1:
dev: true
engines:
node: '>=8'
resolution:
@ -2336,11 +2338,13 @@ packages:
/shebang-command/2.0.0:
dependencies:
shebang-regex: 3.0.0
dev: true
engines:
node: '>=8'
resolution:
integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==
/shebang-regex/3.0.0:
dev: true
engines:
node: '>=8'
resolution:
@ -2773,6 +2777,7 @@ packages:
/which/2.0.2:
dependencies:
isexe: 2.0.0
dev: true
engines:
node: '>= 8'
hasBin: true
@ -2882,16 +2887,9 @@ packages:
/yallist/4.0.0:
resolution:
integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
/yarpm/1.1.1:
dependencies:
command-exists: 1.2.9
cross-spawn: 7.0.3
dev: false
hasBin: true
resolution:
integrity: sha512-A3gVdtyld+gYcVmKScvJqS2oT/i9xdsb/SqDsY9c0+BeYdYBUJrRfr4pD7UP+5uXEneJ0BL0rC/6rd1fnlYEcg==
specifiers:
'@eartharoid/i18n': ^0.0.1
command-exists: ^1.2.9
discord.js: ^12.5.1
dotenv: ^8.2.0
eslint: ^7.20.0
@ -2908,4 +2906,3 @@ specifiers:
sqlite3: ^5.0.2
tedious: ^11.0.3
terminal-link: ^2.1.1
yarpm: ^1.1.1

View File

@ -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);

View File

@ -1,8 +1,5 @@
module.exports = {
event: 'messageReactionAdd',
execute: (client, r, u) => {
client.log.info('messageReactionAdd');
console.log(r);
console.log(u);
}
};

View File

@ -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}"`);
}
};

View File

@ -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));
}
};

View File

@ -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();
}
}
});
};

View File

@ -23,6 +23,19 @@
*/
module.exports = {
debug: false,
defaults: {
colour: '#009999',
locale: 'en-GB'
},
logs: {
enabled: true,
keep_for: 30
},
plugins: [
// 'dsctickets.plugin-name'
'discordtickets-portal'
],
portal: {
enabled: false,
host: 'https://tickets.example.com'
@ -41,14 +54,5 @@ module.exports = {
type: 'WATCHING'
},
],
defaults: {
colour: '#009999',
locale: 'en-GB'
},
logs: {
enabled: true,
keep_for: 30
},
debug: false,
update_notice: true,
};