Require events at runtine

Fixes #9
merge-requests/12/merge
Bsian 2020-05-21 09:26:28 +01:00
parent 6278ba6821
commit 13b915ab5a
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
2 changed files with 3 additions and 5 deletions

View File

@ -3,8 +3,6 @@ import mongoose from 'mongoose';
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import { Collection, Command, Util, ServerManagement, Event } from '.'; import { Collection, Command, Util, ServerManagement, Event } from '.';
import { Member, MemberInterface, Moderation, ModerationInterface, Redirect, RedirectInterface } from '../models'; import { Member, MemberInterface, Moderation, ModerationInterface, Redirect, RedirectInterface } from '../models';
import * as eventFiles from '../events';
import * as commandFiles from '../commands';
export default class Client extends eris.Client { export default class Client extends eris.Client {
public config: { token: string, prefix: string, guildID: string, mongoDB: string }; public config: { token: string, prefix: string, guildID: string, mongoDB: string };
@ -49,7 +47,7 @@ export default class Client extends eris.Client {
}); });
} }
public async loadEvents() { public async loadEvents(eventFiles: { [s: string]: typeof Event; } | ArrayLike<typeof Event>) {
const evtFiles = Object.entries<new(client: Client) => Event>(eventFiles); const evtFiles = Object.entries<new(client: Client) => Event>(eventFiles);
for (const [name, Ev] of evtFiles) { for (const [name, Ev] of evtFiles) {
const event = new Ev(this); const event = new Ev(this);
@ -60,7 +58,7 @@ export default class Client extends eris.Client {
} }
} }
public async loadCommands() { public async loadCommands(commandFiles: { [s: string]: typeof Command; } | ArrayLike<typeof Command>) {
const cmdFiles = Object.values<new(client: Client) => Command>(commandFiles); const cmdFiles = Object.values<new(client: Client) => Command>(commandFiles);
for (const Cmd of cmdFiles) { for (const Cmd of cmdFiles) {
const command = new Cmd(this); const command = new Cmd(this);

View File

@ -2,7 +2,7 @@
"compilerOptions": { "compilerOptions": {
/* Basic Options */ /* Basic Options */
// "incremental": true, /* Enable incremental compilation */ // "incremental": true, /* Enable incremental compilation */
"target": "ES2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "target": "ES2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */ // "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */ // "allowJs": true, /* Allow javascript files to be compiled. */