client changes

merge-requests/4/head
Matthew 2020-05-02 02:35:32 -04:00
parent 688e243839
commit 9f2fdc6a17
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
1 changed files with 9 additions and 5 deletions

View File

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