Merge branch 'dev'
commit
0fe603fd0e
|
@ -70,7 +70,7 @@ 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): Promise<{status: boolean, message: string}> {
|
||||
public async page(recipientNumber: string, senderNumber: string, code: string, message: Message, options?: { emergencyNumber: string }): Promise<{status: boolean, message: string}> {
|
||||
try {
|
||||
const senderEntry = await this.client.db.PagerNumber.findOne({ num: senderNumber });
|
||||
if (!senderEntry) {
|
||||
|
@ -80,29 +80,29 @@ export default class Page extends Command {
|
|||
switch (recipientNumber) {
|
||||
case '#0':
|
||||
this.local.departmentNumbers.forEach(async (num) => {
|
||||
await this.page(num, '#0', code, message);
|
||||
await this.page(num, senderNumber, code, message, { emergencyNumber: '0' });
|
||||
});
|
||||
break;
|
||||
case '#1':
|
||||
await this.page('00', '#1', code, message);
|
||||
await this.page('01', '#1', code, message);
|
||||
await this.page('10', '#1', code, message);
|
||||
await this.page('20', '#1', code, message);
|
||||
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' });
|
||||
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, message);
|
||||
await this.page(bsian?.num, '#2', code, message);
|
||||
await this.page(nightraven?.num, '#2', code, message);
|
||||
await this.page('10', '#2', code, message);
|
||||
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' });
|
||||
break;
|
||||
case '#3':
|
||||
await this.page('00', '#3', code, message);
|
||||
await this.page('01', '#3', code, message);
|
||||
await this.page('20', '#3', code, message);
|
||||
await this.page('21', '#3', code, message);
|
||||
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' });
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -122,22 +122,31 @@ 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;
|
||||
if (!recipient || !sender) {
|
||||
this.logPage({ number: senderNumber, user: 'N/A' }, { number: recipientNumber, user: 'N/A' }, 'discord', code);
|
||||
} else {
|
||||
this.logPage({ number: senderNumber, user: `${sender.username}#${sender.discriminator}` }, { number: recipientNumber, user: `${recipient.username}#${recipient.discriminator}` }, 'discord', 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)})`);
|
||||
}
|
||||
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)})`);
|
||||
}
|
||||
for (const email of recipientEntry.emailAddresses) {
|
||||
const recipient = this.client.guilds.get(this.client.config.guildID).members.get(recipientEntry.individualAssignID);
|
||||
const sender = this.client.guilds.get(this.client.config.guildID).members.get(senderEntry.individualAssignID);
|
||||
this.logPage({ number: senderNumber, user: `${sender.username}#${sender.discriminator}` }, { number: recipientNumber, user: `${recipient.username}#${recipient.discriminator}` }, 'email', code);
|
||||
if (!recipient || !sender) {
|
||||
this.logPage({ number: senderNumber, user: 'N/A' }, { number: recipientNumber, user: 'N/A' }, 'discord', code);
|
||||
} else {
|
||||
this.logPage({ number: senderNumber, user: `${sender.username}#${sender.discriminator}` }, { number: recipientNumber, user: `${recipient.username}#${recipient.discriminator}` }, 'discord', code);
|
||||
}
|
||||
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><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)})`,
|
||||
});
|
||||
}
|
||||
return { status: true, message: `Page to \`${recipientNumber}\` sent.` };
|
||||
} catch (err) {
|
||||
this.client.util.signale.error(err);
|
||||
return { status: false, message: `Error during Processing: ${err}` };
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue