From 9d4f3da073e2a8d8d933b8e3de7d0da47b11f4fd Mon Sep 17 00:00:00 2001 From: Matthew R Date: Tue, 16 Jun 2020 22:34:17 -0400 Subject: [PATCH 1/2] log pages --- src/commands/page.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/commands/page.ts b/src/commands/page.ts index 10982c1..8e747b9 100644 --- a/src/commands/page.ts +++ b/src/commands/page.ts @@ -1,7 +1,7 @@ /* eslint-disable no-case-declarations */ /* eslint-disable no-continue */ /* eslint-disable no-await-in-loop */ -import { Message } from 'eris'; +import { Message, TextableChannel, Textable } from 'eris'; import { Client, Command, RichEmbed } from '../class'; export default class Page extends Command { @@ -64,6 +64,11 @@ export default class Page extends Command { } } + public logPage(sender: { number: string, user?: string }, recipient: { number: string, user?:string }, code: string): void { + const chan = this.client.guilds.get(this.client.config.guildID).channels.get('722636436716781619'); + chan.createMessage(`***\`${sender.number} (${sender.user ? sender.user : ''})\` sent a page to \`${recipient.number} (${recipient.user ? recipient.user : ''})\` with code \`${code}\`.***`); + } + public async page(recipientNumber: string, senderNumber: string, code: string, message: Message): Promise<{status: boolean, message: string}> { try { const senderEntry = await this.client.db.PagerNumber.findOne({ num: senderNumber }); @@ -112,13 +117,17 @@ export default class Page extends Command { } for (const id of recipientEntry.discordIDs) { + 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 chan = await this.client.getDMChannel(id); if (!chan) continue; + this.logPage({ number: senderNumber, user: `${sender.username}#${sender.discriminator}` }, { number: recipientNumber, user: `${recipient.username}#${recipient.discriminator}` }, 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 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}` }, code); await this.client.util.transporter.sendMail({ from: '"LOC Paging System" ', to: email, From abe5af2f919c8c0cc953afb4e2c0fc7315ea4e2c Mon Sep 17 00:00:00 2001 From: Matthew R Date: Tue, 16 Jun 2020 22:35:26 -0400 Subject: [PATCH 2/2] log pages --- src/commands/page.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commands/page.ts b/src/commands/page.ts index 8e747b9..6ebc84b 100644 --- a/src/commands/page.ts +++ b/src/commands/page.ts @@ -67,6 +67,7 @@ export default class Page extends Command { public logPage(sender: { number: string, user?: string }, recipient: { number: string, user?:string }, code: string): void { const chan = this.client.guilds.get(this.client.config.guildID).channels.get('722636436716781619'); chan.createMessage(`***\`${sender.number} (${sender.user ? sender.user : ''})\` sent a page to \`${recipient.number} (${recipient.user ? recipient.user : ''})\` with code \`${code}\`.***`); + this.client.util.signale.log(`PAGE | TO: ${recipient.number}, FROM: ${sender.number}, code: ${code}`); } public async page(recipientNumber: string, senderNumber: string, code: string, message: Message): Promise<{status: boolean, message: string}> {