merge-requests/15/head
Matthew 2020-07-05 14:42:38 -04:00
parent e1fcb15747
commit e39ebfd140
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
19 changed files with 1185 additions and 1184 deletions

View File

@ -24,8 +24,8 @@ export default class Info extends Command {
embed.addField('Discord Library', `Eris (${erisVersion})`, true);
embed.addField('HTTP Server Library', `Express (${expressVersion})`, true);
embed.addField('Database Library', `MongoDB w/ Mongoose ODM (${mongooseVersion})`, true);
embed.addField('Repository', 'https://gitlab.libraryofcode.org/engineering/communityrelations | Licensed under GNU Affero General Public License V3', true);
embed.addField('Memory Usage', `${Math.round(process.memoryUsage().rss / 1024 / 1024)} MB / ${Math.round(totalmem() / 1024 / 1024 / 1024)} GB`, true);
embed.addField('Repository', 'https://loc.sh/crgit | Licensed under GNU Affero General Public License V3', true);
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp();
message.channel.createMessage({ embed });

View File

@ -1,7 +1,7 @@
/* eslint-disable no-case-declarations */
/* eslint-disable no-continue */
/* eslint-disable no-await-in-loop */
import { Message, TextableChannel, Textable } from 'eris';
import { Message, TextableChannel } from 'eris';
import { Client, Command, RichEmbed } from '../class';
export default class Page extends Command {
@ -11,7 +11,7 @@ export default class Page extends Command {
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.usage = 'page <pager number> <pager code> [optional message]';
this.aliases = ['p'];
this.permissions = 1;
this.enabled = true;
@ -52,7 +52,7 @@ export default class Page extends Command {
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], message);
const page = await this.page(args[0], sender.num, args[1], message, args[2] ? args.slice(2).join(' ') : undefined);
if (page.status === true) {
loading.delete();
return this.success(message.channel, page.message);
@ -70,8 +70,9 @@ export default class Page extends Command {
this.client.util.signale.log(`PAGE (${type.toUpperCase()})| TO: ${recipient.number}, FROM: ${sender.number}, CODE: ${code}`);
}
public async page(recipientNumber: string, senderNumber: string, code: string, message: Message, options?: { emergencyNumber: string }): Promise<{status: boolean, message: string}> {
public async page(recipientNumber: string, senderNumber: string, code: string, message: Message, txt?: string, options?: { emergencyNumber: string }): Promise<{status: boolean, message: string}> {
try {
if (txt?.length >= 140) return { status: false, message: 'Your message must be less than 141 characters.' };
const senderEntry = await this.client.db.PagerNumber.findOne({ num: senderNumber });
if (!senderEntry) {
return { status: false, message: 'You do not have a Pager Number.' };
@ -80,29 +81,29 @@ export default class Page extends Command {
switch (recipientNumber) {
case '#0':
this.local.departmentNumbers.forEach(async (num) => {
await this.page(num, senderNumber, code, message, { emergencyNumber: '0' });
await this.page(num, senderNumber, code, message, txt, { emergencyNumber: '0' });
});
break;
case '#1':
await this.page('00', senderNumber, code, message, { emergencyNumber: '0' });
await this.page('01', senderNumber, code, message, { emergencyNumber: '0' });
await this.page('10', senderNumber, code, message, { emergencyNumber: '0' });
await this.page('20', senderNumber, code, message, { emergencyNumber: '0' });
await this.page('00', senderNumber, code, message, txt, { emergencyNumber: '0' });
await this.page('01', senderNumber, code, message, txt, { emergencyNumber: '0' });
await this.page('10', senderNumber, code, message, txt, { emergencyNumber: '0' });
await this.page('20', senderNumber, code, message, txt, { emergencyNumber: '0' });
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, senderNumber, code, message, { emergencyNumber: '0' });
await this.page(bsian?.num, senderNumber, code, message, { emergencyNumber: '0' });
await this.page(nightraven?.num, senderNumber, code, message, { emergencyNumber: '0' });
await this.page('10', senderNumber, code, message, { emergencyNumber: '0' });
await this.page(matthew?.num, senderNumber, code, message, txt, { emergencyNumber: '0' });
await this.page(bsian?.num, senderNumber, code, message, txt, { emergencyNumber: '0' });
await this.page(nightraven?.num, senderNumber, code, message, txt, { emergencyNumber: '0' });
await this.page('10', senderNumber, code, message, txt, { emergencyNumber: '0' });
break;
case '#3':
await this.page('00', senderNumber, code, message, { emergencyNumber: '0' });
await this.page('01', senderNumber, code, message, { emergencyNumber: '0' });
await this.page('20', senderNumber, code, message, { emergencyNumber: '0' });
await this.page('21', senderNumber, code, message, { emergencyNumber: '0' });
await this.page('00', senderNumber, code, message, txt, { emergencyNumber: '0' });
await this.page('01', senderNumber, code, message, txt, { emergencyNumber: '0' });
await this.page('20', senderNumber, code, message, txt, { emergencyNumber: '0' });
await this.page('21', senderNumber, code, message, txt, { emergencyNumber: '0' });
break;
default:
break;
@ -127,7 +128,7 @@ export default class Page extends Command {
} else {
this.logPage({ number: senderNumber, user: `${sender.username}#${sender.discriminator}` }, { number: recipientNumber, user: `${recipient.username}#${recipient.discriminator}` }, 'discord', code);
}
chan.createMessage(`${options?.emergencyNumber ? `[SEN#${options.emergencyNumber}] ` : ''}__**Page**__\n**Recipient PN:** ${recipientNumber}\n**Sender PN:** ${senderNumber} (${sender ? `${sender.username}#${sender.discriminator}` : ''})\n**Initial Command:** https://discordapp.com/channels/${message.guild.id}/${message.channel.id}/${message.id} (<#${message.channel.id}>)\n\n**Pager Code:** ${code} (${this.local.codeDict.get(code)})`);
chan.createMessage(`${options?.emergencyNumber ? `[SEN#${options.emergencyNumber}] ` : ''}__**Page**__\n**Recipient PN:** ${recipientNumber}\n**Sender PN:** ${senderNumber} (${sender ? `${sender.username}#${sender.discriminator}` : ''})\n**Initial Command:** https://discordapp.com/channels/${message.guild.id}/${message.channel.id}/${message.id} (<#${message.channel.id}>)\n\n**Pager Code:** ${code} (${this.local.codeDict.get(code)})${txt ? `\n**Message:** ${txt}` : ''}`);
}
for (const email of recipientEntry.emailAddresses) {
const recipient = this.client.guilds.get(this.client.config.guildID).members.get(recipientEntry.individualAssignID);
@ -141,7 +142,7 @@ export default class Page extends Command {
from: '"LOC Paging System" <internal@libraryofcode.org>',
to: email,
subject: `PAGE FROM ${recipientNumber}`,
html: `<h1>Page</h1>${options?.emergencyNumber ? `<h2>[SEN#${options.emergencyNumber}]` : ''}<strong>Recipient PN:</strong> ${recipientNumber}<br><strong>Sender PN:</strong> ${senderNumber} (${sender ? `${sender.username}#${sender.discriminator}` : ''})<br><strong>Initial Command:</strong> https://discordapp.com/channels/${message.guild.id}/${message.channel.id}/${message.id} (<#${message.channel.id}>)<br><br><strong>Pager Code:</strong> ${code} (${this.local.codeDict.get(code)})`,
html: `<h1>Page</h1>${options?.emergencyNumber ? `<h2>[SEN#${options.emergencyNumber}]` : ''}<strong>Recipient PN:</strong> ${recipientNumber}<br><strong>Sender PN:</strong> ${senderNumber} (${sender ? `${sender.username}#${sender.discriminator}` : ''})<br><strong>Initial Command:</strong> https://discordapp.com/channels/${message.guild.id}/${message.channel.id}/${message.id} (<#${message.channel.id}>)<br><br><strong>Pager Code:</strong> ${code} (${this.local.codeDict.get(code)})${txt ? `<br><strong>Message:</strong> ${txt}` : ''}`,
});
}
return { status: true, message: `Page to \`${recipientNumber}\` sent.` };