diff --git a/src/Client.ts b/src/Client.ts index 9e1a074..236897d 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -5,7 +5,7 @@ import signale from 'signale'; import fs from 'fs-extra'; import config from './config.json'; import { Server } from './api'; -import { Account, AccountInterface, Moderation, ModerationInterface, Domain, DomainInterface } from './models'; +import { Account, AccountInterface, Moderation, ModerationInterface, Domain, DomainInterface, Tier, TierInterface } from './models'; import { emojis } from './stores'; import { Command, Util, Collection } from './class'; import * as commands from './commands'; @@ -18,12 +18,14 @@ export default class Client extends Eris.Client { public commands: Collection; - public db: { Account: mongoose.Model; Domain: mongoose.Model; Moderation: mongoose.Model; }; + public db: { Account: mongoose.Model; Domain: mongoose.Model; Moderation: mongoose.Model; Tier: mongoose.Model; }; public redis: Redis.Redis; public stores: { emojis: { success: string, loading: string, error: string }; }; + public functions: Collection; + public signale: signale.Signale; public server: Server; @@ -39,7 +41,8 @@ export default class Client extends Eris.Client { this.config = config; this.util = new Util(this); this.commands = new Collection(); - this.db = { Account, Domain, Moderation }; + this.functions = new Collection(); + this.db = { Account, Domain, Moderation, Tier }; this.redis = new Redis(); this.stores = { emojis }; this.signale = signale; @@ -64,9 +67,10 @@ export default class Client extends Eris.Client { private async loadFunctions() { const functions = await fs.readdir('./functions'); functions.forEach(async (func) => { - if (func === 'index.ts' || func === 'index.js' || func === 'dataConversion.js') return; + if (func === 'index.ts' || func === 'index.js') return; try { - (require(`./functions/${func}`).default)(this); + const funcRequire: Function = require(`./functions/${func}`).default; + this.functions.set(func.split('.')[0], funcRequire); } catch (error) { this.signale.error(`Error occured loading ${func}`); await this.util.handleError(error);