add reference to page recipient messages

merge-requests/6/merge
Matthew 2020-06-15 23:00:49 -04:00
parent 8ad1fdc0cc
commit cdbd835a76
No known key found for this signature in database
GPG Key ID: F841AB9BF496C194
1 changed files with 14 additions and 3 deletions

View File

@ -5,7 +5,7 @@ import { Message } from 'eris';
import { Client, Command, RichEmbed } from '../class';
export default class Page extends Command {
public local: { emergencyNumbers: string[], departmentNumbers: string[], validPagerCodes: string[] };
public local: { emergencyNumbers: string[], departmentNumbers: string[], validPagerCodes: string[], codeDict: Map<string, string>, };
constructor(client: Client) {
super(client);
@ -20,9 +20,20 @@ export default class Page extends Command {
emergencyNumbers: ['#0', '#1', '#2', '#3'],
departmentNumbers: ['00', '01', '10', '20', '21', '22'],
validPagerCodes: ['911', '811', '210', '265', '411', '419', '555'],
codeDict: new Map(),
};
}
public init() {
this.local.codeDict.set('911', 'Sender is requesting EMERGENCY assistance.');
this.local.codeDict.set('811', 'Sender is requesting immediate/ASAP assistance.');
this.local.codeDict.set('210', 'Sender is informing you they acknowledged your request, usually sent in response to OK the initial page. (10-4)');
this.local.codeDict.set('265', 'Sender is requesting that you check your email.');
this.local.codeDict.set('411', 'Sender is requesting information/counsel from you.');
this.local.codeDict.set('419', 'Sender didn\'t recognize your request.');
this.local.codeDict.set('555', 'Sender is requesting that you contact them.');
}
public async run(message: Message, args: string[]) {
try {
if (!args[0]) {
@ -102,7 +113,7 @@ export default class Page extends Command {
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**Initial Command:** https://discordapp.com/channels/${message.guild.id}/${message.channel.id}/${message.id} (<#${message.channel.id}>)\n\n**Pager Code:** ${code}`);
chan.createMessage(`__**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)})`);
}
for (const email of recipientEntry.emailAddresses) {
const sender = this.client.guilds.get(this.client.config.guildID).members.get(senderEntry.individualAssignID);
@ -110,7 +121,7 @@ export default class Page extends Command {
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><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}`,
html: `<h1>Page</h1><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)})`,
});
}
return { status: true, message: `Page to \`${recipientNumber}\` sent.` };