From 9ddc800e2a30f60600fa700e01eb460deb084ef1 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Fri, 24 Apr 2020 23:46:29 -0400 Subject: [PATCH] add new Member model --- src/class/Client.ts | 6 +++--- src/models/Member.ts | 17 +++++++++++++++++ src/models/index.ts | 1 + 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 src/models/Member.ts diff --git a/src/class/Client.ts b/src/class/Client.ts index 589ff0f..29212bb 100644 --- a/src/class/Client.ts +++ b/src/class/Client.ts @@ -2,7 +2,7 @@ import eris from 'eris'; import mongoose from 'mongoose'; import { promises as fs } from 'fs'; import { Collection, Command, Util } from '.'; -import { Moderation, ModerationInterface } from '../models'; +import { Member, MemberInterface, Moderation, ModerationInterface } from '../models'; export default class Client extends eris.Client { public config: { token: string, prefix: string, guildID: string, mongoDB: string }; @@ -13,14 +13,14 @@ export default class Client extends eris.Client { public util: Util; - public db: { moderation: mongoose.Model }; + public db: { member: mongoose.Model, moderation: mongoose.Model }; // eslint-disable-next-line @typescript-eslint/no-useless-constructor constructor(token: string, options?: eris.ClientOptions) { super(token, options); this.commands = new Collection(); this.intervals = new Collection(); - this.db = { moderation: Moderation }; + this.db = { member: Member, moderation: Moderation }; } public async loadDatabase() { diff --git a/src/models/Member.ts b/src/models/Member.ts new file mode 100644 index 0000000..f8c496b --- /dev/null +++ b/src/models/Member.ts @@ -0,0 +1,17 @@ +import { Document, Schema, model } from 'mongoose'; + +export interface MemberInterface extends Document { + userID: string + additional: { + langs: ['js', 'py', 'rb', 'ts', 'rs', 'go', 'cfam', 'csharp', 'swift', 'java', 'kt', 'asm'], + }, +} + +const Member: Schema = new Schema({ + userID: String, + additional: { + langs: Array, + }, +}); + +export default model('Member', Member); diff --git a/src/models/index.ts b/src/models/index.ts index a149275..81202ce 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -1 +1,2 @@ +export { default as Member, MemberInterface } from './Member'; export { default as Moderation, ModerationInterface } from './Moderation';