From 5dbd497f883247e42430660862cc85fd9ae04f5f Mon Sep 17 00:00:00 2001 From: Matthew R Date: Thu, 17 Oct 2019 15:42:57 -0400 Subject: [PATCH 1/3] find Domain model to client.db --- src/Client.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Client.ts b/src/Client.ts index 7cdf0ff..47929b3 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -6,6 +6,7 @@ import fs from 'fs-extra'; import path from 'path'; import config from './config.json'; import Account, { AccountInterface } from './models/Account'; +import Domain, { DomainInterface } from './models/Domain'; import Moderation, { ModerationInterface } from './models/Moderation'; import emojis from './stores/emojis'; import Util from './Util'; @@ -19,7 +20,7 @@ export default class Client extends Eris.Client { public aliases: Map; - public db: { Account: mongoose.Model; Moderation: mongoose.Model; }; + public db: { Account: mongoose.Model; Domain: mongoose.Model; Moderation: mongoose.Model; }; public stores: { emojis: { success: string, loading: string, error: string }; }; @@ -29,7 +30,7 @@ export default class Client extends Eris.Client { this.util = new Util(this); this.commands = new Map(); this.aliases = new Map(); - this.db = { Account, Moderation }; + this.db = { Account, Domain, Moderation }; this.stores = { emojis }; } From 83452d5184819458962d026edb84cc86364a3886 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Thu, 17 Oct 2019 15:43:10 -0400 Subject: [PATCH 2/3] new domain/port model for CWG --- src/models/Domain.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/models/Domain.ts diff --git a/src/models/Domain.ts b/src/models/Domain.ts new file mode 100644 index 0000000..ee8ade0 --- /dev/null +++ b/src/models/Domain.ts @@ -0,0 +1,24 @@ +import { Document, Schema, model } from 'mongoose'; +import { AccountInterface } from './Account'; + +export interface DomainInterface extends Document { + account: AccountInterface, + domain: string, + port: number, + // Below is the full absolute path to the location of the x509 certificate and key files. + x509: { + cert: string, + key: string + }, + enabled: true +} + +const Domain: Schema = new Schema({ + account: Object, + domain: String, + port: Number, + x509: { cert: String, key: String }, + enabled: Boolean, +}); + +export default model('Domain', Domain); From ba27e52e0cb319e15cd2cc61b40f590553ee2a8f Mon Sep 17 00:00:00 2001 From: Matthew R Date: Thu, 17 Oct 2019 15:43:32 -0400 Subject: [PATCH 3/3] Util class is binded to client, no need to make another class for each command --- src/commands/lock.ts | 5 +---- src/commands/modlogs.ts | 1 + src/commands/ping.ts | 5 +---- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/commands/lock.ts b/src/commands/lock.ts index 051118a..da8ebc8 100644 --- a/src/commands/lock.ts +++ b/src/commands/lock.ts @@ -2,11 +2,8 @@ import fs from 'fs-extra'; import { Message } from 'eris'; import Client from '../Client'; import Command from '../class/Command'; -import Util from '../Util'; export default class Lock extends Command { - util: Util = new Util(this.client) - constructor(client: Client) { super(client); this.name = 'lock'; @@ -21,7 +18,7 @@ export default class Lock extends Command { if (!account) return message.channel.createMessage(`***${this.client.stores.emojis.error} Cannot find user.***`); const edit = await message.channel.createMessage(`***${this.client.stores.emojis.loading} Locking account...***`); } catch (error) { - return this.util.handleError(error, message, this); + return this.client.util.handleError(error, message, this); } } } diff --git a/src/commands/modlogs.ts b/src/commands/modlogs.ts index af96f6f..6a7288c 100644 --- a/src/commands/modlogs.ts +++ b/src/commands/modlogs.ts @@ -1,4 +1,5 @@ import { Message } from 'eris'; +// eslint-disable-next-line import/no-unresolved import { createPaginationEmbed } from 'eris-pagination'; import Client from '../Client'; import Command from '../class/Command'; diff --git a/src/commands/ping.ts b/src/commands/ping.ts index c6c1681..00db1bc 100644 --- a/src/commands/ping.ts +++ b/src/commands/ping.ts @@ -1,11 +1,8 @@ import { Message } from 'eris'; import Client from '../Client'; import Command from '../class/Command'; -import Util from '../Util'; export default class Ping extends Command { - util: Util = new Util(this.client) - constructor(client: Client) { super(client); this.name = 'ping'; @@ -19,7 +16,7 @@ export default class Ping extends Command { const msg: Message = await message.channel.createMessage('🏓 Pong!'); msg.edit(`🏓 Pong!\nClient: \`${Date.now() - clientStart}ms\`\nResponse: \`${msg.createdAt - message.createdAt}ms\``); } catch (error) { - this.util.handleError(error, message, this); + this.client.util.handleError(error, message, this); } } }