From 70c7e3f698fa156e570785d04a8ffd152e606483 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Sat, 26 Oct 2019 00:02:44 -0400 Subject: [PATCH] bind new util and new load functions func --- src/Client.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Client.ts b/src/Client.ts index 901fc67..bfd8fe2 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -3,10 +3,10 @@ import mongoose from 'mongoose'; import signale from 'signale'; import fs from 'fs-extra'; import path from 'path'; -import { config, Util } from '.'; +import { config } from '.'; import { Account, AccountInterface, Moderation, ModerationInterface, Domain, DomainInterface } from './models'; import { emojis } from './stores'; -import { Command } from './class'; +import { Command, Util } from './class'; export default class Client extends Eris.Client { @@ -39,6 +39,19 @@ export default class Client extends Eris.Client { displayTimestamp: true, displayFilename: true, }); + this.loadFunctions(); + this.init(); + } + + private async loadFunctions() { + const functions = await fs.readdir('./functions'); + functions.forEach(async (func) => { + try { + require(`./functions/${func}`).default(this); + } catch (error) { + await this.util.handleError(error); + } + }); } public loadCommand(commandPath: string) {