fix SEN/department paging issue
parent
f45e9418b3
commit
d687ad6b79
|
@ -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}`);
|
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 {
|
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) {
|
||||||
|
@ -80,29 +80,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, message);
|
await this.page(num, senderNumber, code, message, { emergencyNumber: '0' });
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case '#1':
|
case '#1':
|
||||||
await this.page('00', '#1', code, message);
|
await this.page('00', senderNumber, code, message, { emergencyNumber: '0' });
|
||||||
await this.page('01', '#1', code, message);
|
await this.page('01', senderNumber, code, message, { emergencyNumber: '0' });
|
||||||
await this.page('10', '#1', code, message);
|
await this.page('10', senderNumber, code, message, { emergencyNumber: '0' });
|
||||||
await this.page('20', '#1', code, message);
|
await this.page('20', senderNumber, code, message, { emergencyNumber: '0' });
|
||||||
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, message);
|
await this.page(matthew?.num, senderNumber, code, message, { emergencyNumber: '0' });
|
||||||
await this.page(bsian?.num, '#2', code, message);
|
await this.page(bsian?.num, senderNumber, code, message, { emergencyNumber: '0' });
|
||||||
await this.page(nightraven?.num, '#2', code, message);
|
await this.page(nightraven?.num, senderNumber, code, message, { emergencyNumber: '0' });
|
||||||
await this.page('10', '#2', code, message);
|
await this.page('10', senderNumber, code, message, { emergencyNumber: '0' });
|
||||||
break;
|
break;
|
||||||
case '#3':
|
case '#3':
|
||||||
await this.page('00', '#3', code, message);
|
await this.page('00', senderNumber, code, message, { emergencyNumber: '0' });
|
||||||
await this.page('01', '#3', code, message);
|
await this.page('01', senderNumber, code, message, { emergencyNumber: '0' });
|
||||||
await this.page('20', '#3', code, message);
|
await this.page('20', senderNumber, code, message, { emergencyNumber: '0' });
|
||||||
await this.page('21', '#3', code, message);
|
await this.page('21', senderNumber, code, message, { emergencyNumber: '0' });
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
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 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;
|
||||||
this.logPage({ number: senderNumber, user: `${sender.username}#${sender.discriminator}` }, { number: recipientNumber, user: `${recipient.username}#${recipient.discriminator}` }, 'discord', code);
|
if (!recipient || !sender) {
|
||||||
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)})`);
|
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(`${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) {
|
for (const email of recipientEntry.emailAddresses) {
|
||||||
const recipient = this.client.guilds.get(this.client.config.guildID).members.get(recipientEntry.individualAssignID);
|
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);
|
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({
|
await this.client.util.transporter.sendMail({
|
||||||
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><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.` };
|
return { status: true, message: `Page to \`${recipientNumber}\` sent.` };
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
this.client.util.signale.error(err);
|
||||||
return { status: false, message: `Error during Processing: ${err}` };
|
return { status: false, message: `Error during Processing: ${err}` };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue