Merge branch 'dev'

merge-requests/13/head
Matthew 2020-06-15 22:25:25 -04:00
commit 231ff21cfa
No known key found for this signature in database
GPG Key ID: F841AB9BF496C194
1 changed files with 17 additions and 17 deletions

View File

@ -39,7 +39,7 @@ export default class Page extends Command {
message.delete(); message.delete();
const loading = await this.loading(message.channel, 'Paging...'); const loading = await this.loading(message.channel, 'Paging...');
const sender = await this.client.db.PagerNumber.findOne({ individualAssignID: message.author.id }); const sender = await this.client.db.PagerNumber.findOne({ individualAssignID: message.author.id });
const page = await this.page(args[0], sender.num, args[1]); const page = await this.page(args[0], sender.num, args[1], message);
if (page.status === true) { if (page.status === true) {
loading.delete(); loading.delete();
return this.success(message.channel, page.message); return this.success(message.channel, page.message);
@ -51,7 +51,7 @@ export default class Page extends Command {
} }
} }
public async page(recipientNumber: string, senderNumber: string, code: string): Promise<{status: boolean, message: string}> { public async page(recipientNumber: string, senderNumber: string, code: string, message: Message): Promise<{status: boolean, message: string}> {
try { try {
const senderEntry = await this.client.db.PagerNumber.findOne({ num: senderNumber }); const senderEntry = await this.client.db.PagerNumber.findOne({ num: senderNumber });
if (!senderEntry) { if (!senderEntry) {
@ -61,29 +61,29 @@ export default class Page extends Command {
switch (recipientNumber) { switch (recipientNumber) {
case '#0': case '#0':
this.local.departmentNumbers.forEach(async (num) => { this.local.departmentNumbers.forEach(async (num) => {
await this.page(num, '#0', code); await this.page(num, '#0', code, message);
}); });
break; break;
case '#1': case '#1':
await this.page('00', '#1', code); await this.page('00', '#1', code, message);
await this.page('01', '#1', code); await this.page('01', '#1', code, message);
await this.page('10', '#1', code); await this.page('10', '#1', code, message);
await this.page('20', '#1', code); await this.page('20', '#1', code, message);
break; break;
case '#2': case '#2':
const matthew = await this.client.db.PagerNumber.findOne({ individualAssignID: '278620217221971968' }); const matthew = await this.client.db.PagerNumber.findOne({ individualAssignID: '278620217221971968' });
const bsian = await this.client.db.PagerNumber.findOne({ individualAssignID: '253600545972027394' }); const bsian = await this.client.db.PagerNumber.findOne({ individualAssignID: '253600545972027394' });
const nightraven = await this.client.db.PagerNumber.findOne({ individualAssignID: '239261547959025665' }); const nightraven = await this.client.db.PagerNumber.findOne({ individualAssignID: '239261547959025665' });
await this.page(matthew?.num, '#2', code); await this.page(matthew?.num, '#2', code, message);
await this.page(bsian?.num, '#2', code); await this.page(bsian?.num, '#2', code, message);
await this.page(nightraven?.num, '#2', code); await this.page(nightraven?.num, '#2', code, message);
await this.page('10', '#2', code); await this.page('10', '#2', code, message);
break; break;
case '#3': case '#3':
await this.page('00', '#3', code); await this.page('00', '#3', code, message);
await this.page('01', '#3', code); await this.page('01', '#3', code, message);
await this.page('20', '#3', code); await this.page('20', '#3', code, message);
await this.page('21', '#3', code); await this.page('21', '#3', code, message);
break; break;
default: default:
break; break;
@ -102,7 +102,7 @@ export default class Page extends Command {
const sender = this.client.guilds.get(this.client.config.guildID).members.get(senderEntry.individualAssignID); const sender = this.client.guilds.get(this.client.config.guildID).members.get(senderEntry.individualAssignID);
const chan = await this.client.getDMChannel(id); const chan = await this.client.getDMChannel(id);
if (!chan) continue; if (!chan) continue;
chan.createMessage(`__**Page**__\n**Recipient PN:** ${recipientNumber}\n**Sender PN:** ${senderNumber} (${sender ? `${sender.username}#${sender.discriminator}` : ''})\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}`);
} }
for (const email of recipientEntry.emailAddresses) { for (const email of recipientEntry.emailAddresses) {
const sender = this.client.guilds.get(this.client.config.guildID).members.get(senderEntry.individualAssignID); const sender = this.client.guilds.get(this.client.config.guildID).members.get(senderEntry.individualAssignID);
@ -110,7 +110,7 @@ export default class Page extends Command {
from: '"LOC Paging System" <internal@libraryofcode.org>', from: '"LOC Paging System" <internal@libraryofcode.org>',
to: email, to: email,
subject: `PAGE FROM ${recipientNumber}`, 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}`, 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}`,
}); });
} }
return { status: true, message: `Page to \`${recipientNumber}\` sent.` }; return { status: true, message: `Page to \`${recipientNumber}\` sent.` };