Merge branch 'dev'

pull/29/head
Matthew 2020-08-17 23:50:29 -04:00
commit 915b4414ac
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
5 changed files with 39 additions and 7 deletions

View File

@ -1,5 +1,5 @@
import { Route, Server } from '../../../class'; import { Route, Server } from '../../../class';
import acknowledgements from '../../../configs/acknowledgements.json'; // import acknowledgements from '../../../configs/acknowledgements.json';
export default class Internal extends Route { export default class Internal extends Route {
constructor(server: Server) { constructor(server: Server) {
@ -22,6 +22,7 @@ export default class Internal extends Route {
if (member.roles.includes('446104438969466890') || member.roles.includes('701481967149121627')) status = true; if (member.roles.includes('446104438969466890') || member.roles.includes('701481967149121627')) status = true;
return res.status(200).json({ staff: status, username: member.user.username, discriminator: member.user.discriminator, nick: member.nick, avatarURL: member.user.avatarURL, pager: pagerNumber?.num }); return res.status(200).json({ staff: status, username: member.user.username, discriminator: member.user.discriminator, nick: member.nick, avatarURL: member.user.avatarURL, pager: pagerNumber?.num });
} }
const acknowledgements = await this.server.client.db.Staff.find().lean().exec();
return res.status(200).json(acknowledgements); return res.status(200).json(acknowledgements);
} catch (err) { } catch (err) {
return this.handleError(err, res); return this.handleError(err, res);

View File

@ -3,7 +3,7 @@ import pluris from 'pluris';
import mongoose from 'mongoose'; import mongoose from 'mongoose';
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import { Collection, Command, LocalStorage, Util, ServerManagement, Event } from '.'; import { Collection, Command, LocalStorage, Util, ServerManagement, Event } from '.';
import { File, FileInterface, Member, MemberInterface, Moderation, ModerationInterface, Note, NoteInterface, PagerNumber, PagerNumberInterface, Rank, RankInterface, Redirect, RedirectInterface, Stat, StatInterface } from '../models'; import { File, FileInterface, Member, MemberInterface, Moderation, ModerationInterface, Note, NoteInterface, PagerNumber, PagerNumberInterface, Rank, RankInterface, Redirect, RedirectInterface, Staff, StaffInterface, Stat, StatInterface } from '../models';
import { Config } from '../../types'; // eslint-disable-line import { Config } from '../../types'; // eslint-disable-line
pluris(eris); pluris(eris);
@ -21,14 +21,14 @@ export default class Client extends eris.Client {
public serverManagement: ServerManagement; public serverManagement: ServerManagement;
public db: { File: mongoose.Model<FileInterface>, Member: mongoose.Model<MemberInterface>, Moderation: mongoose.Model<ModerationInterface>, Note: mongoose.Model<NoteInterface>, PagerNumber: mongoose.Model<PagerNumberInterface>, Rank: mongoose.Model<RankInterface>, Redirect: mongoose.Model<RedirectInterface>, Stat: mongoose.Model<StatInterface>, local: { muted: LocalStorage } }; public db: { File: mongoose.Model<FileInterface>, Member: mongoose.Model<MemberInterface>, Moderation: mongoose.Model<ModerationInterface>, Note: mongoose.Model<NoteInterface>, PagerNumber: mongoose.Model<PagerNumberInterface>, Rank: mongoose.Model<RankInterface>, Redirect: mongoose.Model<RedirectInterface>, Staff: mongoose.Model<StaffInterface>, Stat: mongoose.Model<StatInterface>, local: { muted: LocalStorage } };
constructor(token: string, options?: eris.ClientOptions) { constructor(token: string, options?: eris.ClientOptions) {
super(token, options); super(token, options);
this.commands = new Collection<Command>(); this.commands = new Collection<Command>();
this.events = new Collection<Event>(); this.events = new Collection<Event>();
this.intervals = new Collection<NodeJS.Timeout>(); this.intervals = new Collection<NodeJS.Timeout>();
this.db = { File, Member, Moderation, Note, PagerNumber, Rank, Redirect, Stat, local: { muted: new LocalStorage('muted') } }; this.db = { File, Member, Moderation, Note, PagerNumber, Rank, Redirect, Staff, Stat, local: { muted: new LocalStorage('muted') } };
} }
public async loadDatabase() { public async loadDatabase() {

View File

@ -2,7 +2,7 @@
import moment from 'moment'; import moment from 'moment';
import { Message, Member } from 'eris'; import { Message, Member } from 'eris';
import { Client, Command, RichEmbed } from '../class'; import { Client, Command, RichEmbed } from '../class';
import acknowledgements from '../configs/acknowledgements.json'; // import acknowledgements from '../configs/acknowledgements.json';
import { whois as emotes } from '../configs/emotes.json'; import { whois as emotes } from '../configs/emotes.json';
export default class Whois extends Command { export default class Whois extends Command {
@ -29,7 +29,8 @@ export default class Whois extends Command {
} }
const embed = new RichEmbed(); const embed = new RichEmbed();
embed.setThumbnail(member.avatarURL); embed.setThumbnail(member.avatarURL);
const ackResolve = this.resolveStaffInformation(member.id); // const ackResolve = this.resolveStaffInformation(member.id);
const ackResolve = await this.client.db.Staff.findOne({ userID: member.id }).lean().exec();
let title = `${member.user.username}#${member.user.discriminator}`; let title = `${member.user.username}#${member.user.discriminator}`;
if (ackResolve?.pn?.length > 0) title += `, ${ackResolve.pn.join(', ')}`; if (ackResolve?.pn?.length > 0) title += `, ${ackResolve.pn.join(', ')}`;
embed.setAuthor(title, member.user.avatarURL); embed.setAuthor(title, member.user.avatarURL);
@ -189,7 +190,7 @@ export default class Whois extends Command {
} }
public resolveStaffInformation(id: string) { public resolveStaffInformation(id: string) {
return acknowledgements.find((m) => m.id === id); return null; // acknowledgements.find((m) => m.id === id);
} }
public capsFirstLetter(string?: string): string | void { public capsFirstLetter(string?: string): string | void {

29
src/models/Staff.ts Normal file
View File

@ -0,0 +1,29 @@
import { Document, Schema, model } from 'mongoose';
export interface StaffInterface extends Document {
name: string,
userID: string,
title: string,
dept: string,
pn: string[],
emailAddress: string,
gitlab: string,
github: string,
bio: string,
acknowledgements: string[],
}
const Staff: Schema = new Schema({
name: String,
userID: String,
title: String,
dept: String,
pn: Array,
emailAddress: String,
gitlab: String,
github: String,
bio: String,
acknowledgements: Array,
});
export default model<StaffInterface>('Staff', Staff);

View File

@ -5,4 +5,5 @@ export { default as Note, NoteInterface } from './Note';
export { default as PagerNumber, PagerNumberInterface, PagerNumberRaw } from './PagerNumber'; export { default as PagerNumber, PagerNumberInterface, PagerNumberRaw } from './PagerNumber';
export { default as Rank, RankInterface } from './Rank'; export { default as Rank, RankInterface } from './Rank';
export { default as Redirect, RedirectInterface, RedirectRaw } from './Redirect'; export { default as Redirect, RedirectInterface, RedirectRaw } from './Redirect';
export { default as Staff, StaffInterface } from './Staff';
export { default as Stat, StatInterface } from './Stat'; export { default as Stat, StatInterface } from './Stat';