Merge branch 'dev'

merge-requests/13/head
Matthew 2020-06-15 21:44:16 -04:00
commit 3e5758e73a
No known key found for this signature in database
GPG Key ID: F841AB9BF496C194
10 changed files with 490 additions and 5 deletions

View File

@ -15,6 +15,7 @@
"@types/helmet": "^0.0.47", "@types/helmet": "^0.0.47",
"@types/mongoose": "^5.7.19", "@types/mongoose": "^5.7.19",
"@types/node": "^14.0.1", "@types/node": "^14.0.1",
"@types/nodemailer": "^6.4.0",
"@types/signale": "^1.4.1", "@types/signale": "^1.4.1",
"@types/uuid": "^7.0.3", "@types/uuid": "^7.0.3",
"@typescript-eslint/eslint-plugin": "^2.33.0", "@typescript-eslint/eslint-plugin": "^2.33.0",
@ -32,6 +33,7 @@
"helmet": "^3.22.0", "helmet": "^3.22.0",
"moment": "^2.25.3", "moment": "^2.25.3",
"mongoose": "^5.9.13", "mongoose": "^5.9.13",
"nodemailer": "^6.4.8",
"signale": "^1.4.0", "signale": "^1.4.0",
"uuid": "^8.0.0", "uuid": "^8.0.0",
"yaml": "^1.9.2" "yaml": "^1.9.2"

View File

@ -2,10 +2,10 @@ import eris from 'eris';
import mongoose from 'mongoose'; import mongoose from 'mongoose';
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import { Collection, Command, Util, ServerManagement, Event } from '.'; import { Collection, Command, Util, ServerManagement, Event } from '.';
import { Member, MemberInterface, Moderation, ModerationInterface, Redirect, RedirectInterface } from '../models'; import { Member, MemberInterface, Moderation, ModerationInterface, PagerNumber, PagerNumberInterface, Redirect, RedirectInterface } from '../models';
export default class Client extends eris.Client { export default class Client extends eris.Client {
public config: { token: string, prefix: string, guildID: string, mongoDB: string }; public config: { token: string, prefix: string, guildID: string, mongoDB: string, emailPass: string, };
public commands: Collection<Command>; public commands: Collection<Command>;
@ -17,14 +17,14 @@ export default class Client extends eris.Client {
public serverManagement: ServerManagement; public serverManagement: ServerManagement;
public db: { Member: mongoose.Model<MemberInterface>, Moderation: mongoose.Model<ModerationInterface>, Redirect: mongoose.Model<RedirectInterface> }; public db: { Member: mongoose.Model<MemberInterface>, Moderation: mongoose.Model<ModerationInterface>, PagerNumber: mongoose.Model<PagerNumberInterface>, Redirect: mongoose.Model<RedirectInterface> };
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 = { Member, Moderation, Redirect }; this.db = { Member, Moderation, PagerNumber, Redirect };
} }
public async loadDatabase() { public async loadDatabase() {

View File

@ -1,4 +1,5 @@
/* eslint-disable no-bitwise */ /* eslint-disable no-bitwise */
import nodemailer from 'nodemailer';
import signale from 'signale'; import signale from 'signale';
import { Member, Message, Guild, PrivateChannel, GroupChannel, Role, AnyGuildChannel } from 'eris'; import { Member, Message, Guild, PrivateChannel, GroupChannel, Role, AnyGuildChannel } from 'eris';
import { Client, Command, Moderation, RichEmbed } from '.'; import { Client, Command, Moderation, RichEmbed } from '.';
@ -11,6 +12,8 @@ export default class Util {
public signale: signale.Signale; public signale: signale.Signale;
public transporter: nodemailer.Transporter;
constructor(client: Client) { constructor(client: Client) {
this.client = client; this.client = client;
this.moderation = new Moderation(this.client); this.moderation = new Moderation(this.client);
@ -20,6 +23,11 @@ export default class Util {
displayTimestamp: true, displayTimestamp: true,
displayFilename: true, displayFilename: true,
}); });
this.transporter = nodemailer.createTransport({
host: 'staff.libraryofcode.org',
port: 587,
auth: { user: 'internal', pass: this.client.config.emailPass },
});
} }
get emojis() { get emojis() {

View File

@ -11,6 +11,7 @@ export { default as info } from './info';
export { default as kick } from './kick'; export { default as kick } from './kick';
export { default as listredirects } from './listredirects'; export { default as listredirects } from './listredirects';
export { default as npm } from './npm'; export { default as npm } from './npm';
export { default as page } from './page';
export { default as ping } from './ping'; export { default as ping } from './ping';
export { default as roleinfo } from './roleinfo'; export { default as roleinfo } from './roleinfo';
export { default as unban } from './unban'; export { default as unban } from './unban';

120
src/commands/page.ts Normal file
View File

@ -0,0 +1,120 @@
/* eslint-disable no-case-declarations */
/* eslint-disable no-continue */
/* eslint-disable no-await-in-loop */
import { Message } from 'eris';
import { Client, Command, RichEmbed } from '../class';
export default class Page extends Command {
public local: { emergencyNumbers: string[], departmentNumbers: string[], validPagerCodes: string[] };
constructor(client: Client) {
super(client);
this.name = 'page';
this.description = 'Pages the specified emergency number, department number, or individual number with the specified pager code.';
this.usage = 'page <pager number> <pager code>';
this.permissions = 1;
this.enabled = true;
this.guildOnly = true;
this.local = {
emergencyNumbers: ['#0', '#1', '#2', '#3'],
departmentNumbers: ['00', '01', '10', '20', '21', '22'],
validPagerCodes: ['911', '811', '210', '265', '411', '419', '555'],
};
}
public async run(message: Message, args: string[]) {
try {
if (!args[0]) {
this.client.commands.get('help').run(message, [this.name]);
const embed = new RichEmbed();
embed.setTitle('Special Emergency/Department Numbers & Pager Codes');
embed.addField('Special Emergency Numbers', '`#0` | Broadcast - all Staff/Associates\n`#1` | Authoritative Broadcast - all Directors, Supervisors, Technicians, and Moderators\n`#2` | Systems Administrators/Technicians Broadcast - Matthew, Bsian, NightRaven, and all Technicians\n`#3` | Community/Moderation Team Broadcast - all Directors, Supervisors, Moderators, and Core Team');
embed.addField('Department Numbers', '`00` | Board of Directors\n`01` | Supervisors\n`10` | Technicians\n`20` | Moderators\n`21` | Core Team\n`22` | Associates');
embed.addField('Pager Codes', '"Pager" term in this field refers to the Staff member that initially paged. This is a list of valid codes you can send via a page.\n\n`911` - Pager is requesting EMERGENCY assistance\n`811` - Pager is requesting immediate/ASAP assistance\n`210` - Pager is informing you they acknowledged your request, usually sent in response to OK the initial page.\n`265` - Pager is requesting that you check your email\n`411` - Pager is requesting information/counsel from you\n`419` - Pager didn\'t recognize your request\n`555` - Pager is requesting that you contact them');
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp();
return message.channel.createMessage({ embed });
}
message.delete();
const loading = await this.loading(message.channel, 'Paging...');
const sender = await this.client.db.PagerNumber.findOne({ individualAssignID: message.author.id });
const page = await this.page(args[0], sender.num, args[1]);
if (page.status === true) {
loading.delete();
return this.success(message.channel, page.message);
}
loading.delete();
return this.error(message.channel, page.message);
} catch (err) {
return this.client.util.handleError(err, message, this);
}
}
public async page(recipientNumber: string, senderNumber: string, code: string): Promise<{status: boolean, message: string}> {
try {
const senderEntry = await this.client.db.PagerNumber.findOne({ num: senderNumber });
if (!senderEntry) {
return { status: false, message: 'You do not have a Pager Number.' };
}
if (this.local.emergencyNumbers.includes(recipientNumber)) {
switch (recipientNumber) {
case '#0':
this.local.departmentNumbers.forEach(async (num) => {
await this.page(num, '#0', code);
});
break;
case '#1':
await this.page('00', '#1', code);
await this.page('01', '#1', code);
await this.page('10', '#1', code);
await this.page('20', '#1', code);
break;
case '#2':
const matthew = await this.client.db.PagerNumber.findOne({ individualAssignID: '278620217221971968' });
const bsian = await this.client.db.PagerNumber.findOne({ individualAssignID: '253600545972027394' });
const nightraven = await this.client.db.PagerNumber.findOne({ individualAssignID: '239261547959025665' });
await this.page(matthew?.num, '#2', code);
await this.page(bsian?.num, '#2', code);
await this.page(nightraven?.num, '#2', code);
await this.page('10', '#2', code);
break;
case '#3':
await this.page('00', '#3', code);
await this.page('01', '#3', code);
await this.page('20', '#3', code);
await this.page('21', '#3', code);
break;
default:
break;
}
return { status: true, message: `Page to \`${recipientNumber}\` sent.` };
}
const recipientEntry = await this.client.db.PagerNumber.findOne({ num: recipientNumber });
if (!recipientEntry) {
return { status: false, message: `Pager Number \`${recipientNumber}\` does not exist.` };
}
if (!this.local.validPagerCodes.includes(code)) {
return { status: false, message: 'The Pager Code you provided is invalid.' };
}
for (const id of recipientEntry.discordIDs) {
const sender = this.client.guilds.get(this.client.config.guildID).members.get(senderEntry.individualAssignID);
const chan = await this.client.getDMChannel(id);
if (!chan) continue;
chan.createMessage(`__**Page**__\n**Recipient PN:** ${recipientNumber}\n**Sender PN:** ${senderNumber} (${sender ? `${sender.username}${sender.discriminator}` : ''})\n\n**Pager Code:** ${code}`);
}
for (const email of recipientEntry.emailAddresses) {
const sender = this.client.guilds.get(this.client.config.guildID).members.get(senderEntry.individualAssignID);
await this.client.util.transporter.sendMail({
from: '"LOC Paging System" <internal@libraryofcode.org>',
to: email,
subject: `PAGE FROM ${recipientNumber}`,
html: `<h1>Page</h1><strong>Recipient PN:</strong> ${recipientNumber}<br><strong>Sender PN:</strong> ${senderNumber} (${sender ? `${sender.username}${sender.discriminator}` : ''})<br><br><strong>Pager Code:</strong> ${code}`,
});
}
return { status: true, message: `Page to \`${recipientNumber}\` sent.` };
} catch (err) {
return { status: false, message: `Error during Processing: ${err}` };
}
}
}

View File

@ -0,0 +1,315 @@
/* eslint-disable no-await-in-loop */
import { Client } from '../class';
import { PagerNumberInterface } from '../models';
let interval: NodeJS.Timeout;
async function setupDepartmentCodes(client: Client): Promise<void> {
const directorPagers = await client.db.PagerNumber.findOne({ num: '00' });
const supervisorPagers = await client.db.PagerNumber.findOne({ num: '01' });
const technicianPagers = await client.db.PagerNumber.findOne({ num: '10' });
const moderatorPagers = await client.db.PagerNumber.findOne({ num: '20' });
const coreTeamPagers = await client.db.PagerNumber.findOne({ num: '21' });
const associatePagers = await client.db.PagerNumber.findOne({ num: '22' });
if (!directorPagers) {
const setup = new client.db.PagerNumber({
num: '00',
individualAssignID: '',
emailAddresses: [],
discordIDs: [],
});
await setup.save();
}
if (!supervisorPagers) {
const setup = new client.db.PagerNumber({
num: '01',
individualAssignID: '',
emailAddresses: [],
discordIDs: [],
});
await setup.save();
}
if (!technicianPagers) {
const setup = new client.db.PagerNumber({
num: '10',
individualAssignID: '',
emailAddresses: [],
discordIDs: [],
});
setup.save();
}
if (!moderatorPagers) {
const setup = new client.db.PagerNumber({
num: '20',
individualAssignID: '',
emailAddresses: [],
discordIDs: [],
});
await setup.save();
}
if (!coreTeamPagers) {
const setup = new client.db.PagerNumber({
num: '21',
individualAssignID: '',
emailAddresses: [],
discordIDs: [],
});
await setup.save();
}
if (!associatePagers) {
const setup = new client.db.PagerNumber({
num: '22',
individualAssignID: '',
emailAddresses: [],
discordIDs: [],
});
await setup.save();
}
}
export default function departmentPager(client: Client): NodeJS.Timeout {
setupDepartmentCodes(client);
interval = setInterval(async () => {
const acknowledgements = require(`${__dirname}/../configs/acknowledgements.json`);
function resolveStaffInformation(id: string) {
return acknowledgements.find((m) => m.id === id);
}
await client.guilds.get(client.config.guildID).fetchAllMembers();
const { members } = client.guilds.get(client.config.guildID);
// const takenPagers = new Set<string>();
members.forEach(async (member) => {
let pager = await client.db.PagerNumber.findOne({ individualAssignID: member.id });
// Directors
if (!pager && member.roles.includes('662163685439045632')) {
let randomPagerNumber: string;
let status = true;
// eslint-disable-next-line no-constant-condition
while (status) {
randomPagerNumber = `00${String(Math.floor(Math.random() * 9) + 1)}`;
const check = await client.db.PagerNumber.findOne({ num: randomPagerNumber });
if (check?.num !== randomPagerNumber) status = false;
}
const acknowledgement = resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) return;
const newNumber = new client.db.PagerNumber({
num: randomPagerNumber,
individualAssignID: member.id,
emailAddresses: [acknowledgement.emailAddress],
discordIDs: [member.id],
});
pager = await newNumber.save();
client.getDMChannel(member.id).then((chan) => {
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
});
}
// Supervisors
if (!pager && member.roles.includes('701454855952138300')) {
let randomPagerNumber: string;
let status = true;
// eslint-disable-next-line no-constant-condition
while (status) {
randomPagerNumber = `01${String(Math.floor(Math.random() * 9) + 1)}`;
const check = await client.db.PagerNumber.findOne({ num: randomPagerNumber });
if (check?.num !== randomPagerNumber) status = false;
}
const acknowledgement = resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) return;
const newNumber = new client.db.PagerNumber({
num: randomPagerNumber,
individualAssignID: member.id,
emailAddresses: [acknowledgement.emailAddress],
discordIDs: [member.id],
});
pager = await newNumber.save();
client.getDMChannel(member.id).then((chan) => {
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
});
}
// Technicians
if (!pager && member.roles.includes('701454780828221450')) {
let randomPagerNumber: string;
let status = true;
// eslint-disable-next-line no-constant-condition
while (status) {
randomPagerNumber = `10${String(Math.floor(Math.random() * 99) + 1)}`;
if (randomPagerNumber.length === 3) randomPagerNumber = `${randomPagerNumber}0`;
const check = await client.db.PagerNumber.findOne({ num: randomPagerNumber });
if (check?.num !== randomPagerNumber) status = false;
}
const acknowledgement = resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) return;
const newNumber = new client.db.PagerNumber({
num: randomPagerNumber,
individualAssignID: member.id,
emailAddresses: [acknowledgement.emailAddress],
discordIDs: [member.id],
});
pager = await newNumber.save();
client.getDMChannel(member.id).then((chan) => {
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
});
}
// Moderators
if (!pager && member.roles.includes('455972169449734144')) {
let randomPagerNumber: string;
let status = true;
// eslint-disable-next-line no-constant-condition
while (status) {
randomPagerNumber = `20${String(Math.floor(Math.random() * 99) + 1)}`;
if (randomPagerNumber.length === 3) randomPagerNumber = `${randomPagerNumber}0`;
const check = await client.db.PagerNumber.findOne({ num: randomPagerNumber });
if (check?.num !== randomPagerNumber) status = false;
}
const acknowledgement = resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) return;
const newNumber = new client.db.PagerNumber({
num: randomPagerNumber,
individualAssignID: member.id,
emailAddresses: [acknowledgement.emailAddress],
discordIDs: [member.id],
});
pager = await newNumber.save();
client.getDMChannel(member.id).then((chan) => {
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
});
}
// Core Team
if (!pager && member.roles.includes('453689940140883988')) {
let randomPagerNumber: string;
let status = true;
// eslint-disable-next-line no-constant-condition
while (status) {
randomPagerNumber = `21${String(Math.floor(Math.random() * 999) + 1)}`;
if (randomPagerNumber.length === 4) randomPagerNumber = `${randomPagerNumber}0`;
const check = await client.db.PagerNumber.findOne({ num: randomPagerNumber });
if (check?.num !== randomPagerNumber) status = false;
}
const acknowledgement = resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) return;
const newNumber = new client.db.PagerNumber({
num: randomPagerNumber,
individualAssignID: member.id,
emailAddresses: [acknowledgement.emailAddress],
discordIDs: [member.id],
});
pager = await newNumber.save();
client.getDMChannel(member.id).then((chan) => {
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
});
}
// Associates
if (!pager && member.roles.includes('701481967149121627')) {
let randomPagerNumber: string;
let status = true;
// eslint-disable-next-line no-constant-condition
while (status) {
randomPagerNumber = `22${String(Math.floor(Math.random() * 999) + 1)}`;
if (randomPagerNumber.length === 4) randomPagerNumber = `${randomPagerNumber}0`;
const check = await client.db.PagerNumber.findOne({ num: randomPagerNumber });
if (check?.num !== randomPagerNumber) status = false;
}
const acknowledgement = resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) return;
const newNumber = new client.db.PagerNumber({
num: randomPagerNumber,
individualAssignID: member.id,
emailAddresses: [acknowledgement.emailAddress],
discordIDs: [member.id],
});
pager = await newNumber.save();
client.getDMChannel(member.id).then((chan) => {
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
});
}
});
// Associates
const associatePagers = await client.db.PagerNumber.findOne({ num: '22' });
members.forEach(async (member) => {
if (member.roles.includes('701481967149121627') && !associatePagers.discordIDs.includes(member.id)) {
await associatePagers.updateOne({ $addToSet: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await associatePagers.updateOne({ $addToSet: { emailAddresses: acknowledgement.emailAddress } });
}
if (!member.roles.includes('701481967149121627') && associatePagers.discordIDs.includes(member.id)) {
await associatePagers.updateOne({ $pull: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await associatePagers.updateOne({ $pull: { emailAddresses: acknowledgement.emailAddress } });
}
});
// Core Team
const coreTeamPagers = await client.db.PagerNumber.findOne({ num: '21' });
members.forEach(async (member) => {
if (member.roles.includes('453689940140883988') && !coreTeamPagers.discordIDs.includes(member.id)) {
await coreTeamPagers.updateOne({ $addToSet: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await coreTeamPagers.updateOne({ $addToSet: { emailAddresses: acknowledgement.emailAddress } });
}
if (!member.roles.includes('453689940140883988') && coreTeamPagers.discordIDs.includes(member.id)) {
await coreTeamPagers.updateOne({ $pull: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await coreTeamPagers.updateOne({ $pull: { emailAddresses: acknowledgement.emailAddress } });
}
});
// Moderator
const moderatorPagers = await client.db.PagerNumber.findOne({ num: '20' });
members.forEach(async (member) => {
if (member.roles.includes('455972169449734144') && !moderatorPagers.discordIDs.includes(member.id)) {
await moderatorPagers.updateOne({ $addToSet: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await moderatorPagers.updateOne({ $addToSet: { emailAddresses: acknowledgement.emailAddress } });
}
if (!member.roles.includes('455972169449734144') && moderatorPagers.discordIDs.includes(member.id)) {
await moderatorPagers.updateOne({ $pull: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await moderatorPagers.updateOne({ $pull: { emailAddresses: acknowledgement.emailAddress } });
}
});
// Technician
const technicianPagers = await client.db.PagerNumber.findOne({ num: '10' });
members.forEach(async (member) => {
if (member.roles.includes('701454780828221450') && !technicianPagers.discordIDs.includes(member.id)) {
await technicianPagers.updateOne({ $addToSet: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await technicianPagers.updateOne({ $addToSet: { emailAddresses: acknowledgement.emailAddress } });
}
if (!member.roles.includes('701454780828221450') && technicianPagers.discordIDs.includes(member.id)) {
await technicianPagers.updateOne({ $pull: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await technicianPagers.updateOne({ $pull: { emailAddresses: acknowledgement.emailAddress } });
}
});
// Supervisor
const supervisorPagers = await client.db.PagerNumber.findOne({ num: '01' });
members.forEach(async (member) => {
if (member.roles.includes('701454855952138300') && !supervisorPagers.discordIDs.includes(member.id)) {
await supervisorPagers.updateOne({ $addToSet: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await supervisorPagers.updateOne({ $addToSet: { emailAddresses: acknowledgement.emailAddress } });
}
if (!member.roles.includes('701454855952138300') && supervisorPagers.discordIDs.includes(member.id)) {
await supervisorPagers.updateOne({ $pull: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await supervisorPagers.updateOne({ $pull: { emailAddresses: acknowledgement.emailAddress } });
}
});
// Board of Directors
const directorPagers = await client.db.PagerNumber.findOne({ num: '00' });
members.forEach(async (member) => {
if (member.roles.includes('662163685439045632') && !directorPagers.discordIDs.includes(member.id)) {
await directorPagers.updateOne({ $addToSet: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await directorPagers.updateOne({ $addToSet: { emailAddresses: acknowledgement.emailAddress } });
}
if (!member.roles.includes('662163685439045632') && directorPagers.discordIDs.includes(member.id)) {
await directorPagers.updateOne({ $pull: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await directorPagers.updateOne({ $pull: { emailAddresses: acknowledgement.emailAddress } });
}
});
}, 10000);
return interval;
}

View File

@ -10,7 +10,7 @@ import * as commandFiles from './commands';
async function main(): Promise<void> { async function main(): Promise<void> {
const read = await fs.readFile('../config.yaml', 'utf8'); const read = await fs.readFile('../config.yaml', 'utf8');
const config: { token: string, prefix: string, guildID: string, mongoDB: string } = parse(read); const config: { token: string, prefix: string, guildID: string, mongoDB: string, emailPass: string } = parse(read);
const client = new Client(config.token, { defaultImageFormat: 'png', restMode: true }); const client = new Client(config.token, { defaultImageFormat: 'png', restMode: true });
client.config = config; client.config = config;
await client.loadDatabase(); await client.loadDatabase();

26
src/models/PagerNumber.ts Normal file
View File

@ -0,0 +1,26 @@
import { Document, Schema, model } from 'mongoose';
export interface PagerNumberRaw {
num: string,
// This field will be "" if the pager number doesn't belong to an individual user
individualAssignID: string,
emailAddresses: string[],
discordIDs: string[],
}
export interface PagerNumberInterface extends Document {
num: string,
// This field will be "" if the pager number doesn't belong to an individual user
individualAssignID: string,
emailAddresses: string[],
discordIDs: string[],
}
const PagerNumber: Schema = new Schema({
num: String,
individualAssignID: String,
emailAddresses: Array,
discordIDs: Array,
});
export default model<PagerNumberInterface>('PagerNumber', PagerNumber);

View File

@ -1,3 +1,4 @@
export { default as Member, MemberInterface } from './Member'; export { default as Member, MemberInterface } from './Member';
export { default as Moderation, ModerationInterface } from './Moderation'; export { default as Moderation, ModerationInterface } from './Moderation';
export { default as PagerNumber, PagerNumberInterface, PagerNumberRaw } from './PagerNumber';
export { default as Redirect, RedirectInterface, RedirectRaw } from './Redirect'; export { default as Redirect, RedirectInterface, RedirectRaw } from './Redirect';

View File

@ -119,6 +119,13 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.1.tgz#5d93e0a099cd0acd5ef3d5bde3c086e1f49ff68c" resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.1.tgz#5d93e0a099cd0acd5ef3d5bde3c086e1f49ff68c"
integrity sha512-FAYBGwC+W6F9+huFIDtn43cpy7+SzG+atzRiTfdp3inUKL2hXnd4rG8hylJLIh4+hqrQy1P17kvJByE/z825hA== integrity sha512-FAYBGwC+W6F9+huFIDtn43cpy7+SzG+atzRiTfdp3inUKL2hXnd4rG8hylJLIh4+hqrQy1P17kvJByE/z825hA==
"@types/nodemailer@^6.4.0":
version "6.4.0"
resolved "https://registry.yarnpkg.com/@types/nodemailer/-/nodemailer-6.4.0.tgz#d8c039be3ed685c4719a026455555be82c124b74"
integrity sha512-KY7bFWB0MahRZvVW4CuW83qcCDny59pJJ0MQ5ifvfcjNwPlIT0vW4uARO4u1gtkYnWdhSvURegecY/tzcukJcA==
dependencies:
"@types/node" "*"
"@types/qs@*": "@types/qs@*":
version "6.9.2" version "6.9.2"
resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.2.tgz#faab98ec4f96ee72c829b7ec0983af4f4d343113" resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.2.tgz#faab98ec4f96ee72c829b7ec0983af4f4d343113"
@ -1460,6 +1467,11 @@ nocache@2.1.0:
resolved "https://registry.yarnpkg.com/nocache/-/nocache-2.1.0.tgz#120c9ffec43b5729b1d5de88cd71aa75a0ba491f" resolved "https://registry.yarnpkg.com/nocache/-/nocache-2.1.0.tgz#120c9ffec43b5729b1d5de88cd71aa75a0ba491f"
integrity sha512-0L9FvHG3nfnnmaEQPjT9xhfN4ISk0A8/2j4M37Np4mcDesJjHgEUfgPhdCyZuFI954tjokaIj/A3NdpFNdEh4Q== integrity sha512-0L9FvHG3nfnnmaEQPjT9xhfN4ISk0A8/2j4M37Np4mcDesJjHgEUfgPhdCyZuFI954tjokaIj/A3NdpFNdEh4Q==
nodemailer@^6.4.8:
version "6.4.8"
resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-6.4.8.tgz#aca52886e4e56f71f6b8a65f5ca6b767ca751fc7"
integrity sha512-UbJD0+g5e2H20bWv7Rpj3B+N3TMMJ0MLoLwaGVJ0k3Vo8upq0UltwHJ5BJfrpST1vFa91JQ8cf7cICK5DSIo1Q==
normalize-package-data@^2.3.2: normalize-package-data@^2.3.2:
version "2.5.0" version "2.5.0"
resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8"