From 16203d014dd59393d0d06e19d48982931a936f52 Mon Sep 17 00:00:00 2001 From: mwang2000 <59301359+mwang2000@users.noreply.github.com> Date: Mon, 1 Mar 2021 22:05:31 -0800 Subject: [PATCH] manual verification bug fixes, parser now makes all emails lowercase (#175) * manual verification bug fixes, parser now makes all emails lowercase * fixed undefined type in check-member * notify hacker when ticket deletes due to inactivity --- classes/ticket.js | 8 ++++++-- commands/verification/check-member.js | 2 +- commands/verification/manual-verify.js | 6 +++--- db/firebase/firebase-services.js | 2 +- db/firebase/parser.js | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/classes/ticket.js b/classes/ticket.js index 910d6de4..ec02f4a5 100644 --- a/classes/ticket.js +++ b/classes/ticket.js @@ -296,10 +296,10 @@ class Ticket { if (this.hackers.length === 0) { ticketCollector.stop(); looseAccessCollector.stop(); + this.ticketMsg.edit(this.ticketMsg.embeds[0].setColor('#128c1e').addField('Ticket Closed', 'This ticket has been closed!! Good job!')); await discordServices.deleteChannel(this.voice); await discordServices.deleteChannel(this.text); await discordServices.deleteChannel(this.category); - this.ticketMsg.edit(this.ticketMsg.embeds[0].setColor('#128c1e').addField('Ticket Closed', 'This ticket has been closed!! Good job!')); this.cave.tickets.delete(this.ticketNumber); // delete this ticket from the cave's Collection of active tickets } else if (this.mentors.length === 0) { this.category.updateOverwrite(exitUser, { VIEW_CHANNEL: false, SEND_MESSAGES: false, READ_MESSAGE_HISTORY: false }); @@ -345,7 +345,7 @@ class Ticket { let warning = await this.text.send(requestMsg + 'If the ticket has been solved, please click the 👋 emoji above to leave the channel. ' + 'If you need to keep the channel, please click the emoji below, **otherwise this ticket will be deleted in ** ' + this.bufferTime + ' **minutes**.') - warning.react('🔄'); + await warning.react('🔄'); // reaction collector to listen for someone to react with the emoji for more time const deletionCollector = warning.createReactionCollector((reaction, user) => !user.bot && reaction.emoji.name === '🔄', { time: this.bufferTime * 60 * 1000, max: 1 }); @@ -363,6 +363,10 @@ class Ticket { await discordServices.deleteChannel(this.text); await discordServices.deleteChannel(this.category); this.ticketMsg.edit(this.ticketMsg.embeds[0].setColor('#128c1e').addField('Ticket Closed Due to Inactivity', 'This ticket has been closed!! Good job!')); + discordServices.sendEmbedToMember(this.requester, { + title: 'Ticket Closed!', + description: 'Your ticket number ' + this.ticketNumber + ' was closed due to inactivity. If you need more help, please request another ticket!', + }, false); this.cave.tickets.delete(this.ticketNumber); } } else if (collected.size > 0) { diff --git a/commands/verification/check-member.js b/commands/verification/check-member.js index 3128b944..98762fb1 100644 --- a/commands/verification/check-member.js +++ b/commands/verification/check-member.js @@ -37,7 +37,7 @@ module.exports = class Verification extends PermissionCommand { if (result.length > 0) { // if similar emails were found, print them var listMembers = ''; result.forEach(member => { - var listMember = member.email + ' (' + member.type + ') '; + var listMember = member.email + ' (' + member.types.join(', ') + ') '; listMembers += listMember; }); message.channel.send('Here are the results I found similar to ' + emailOrName + ': ' + listMembers); diff --git a/commands/verification/manual-verify.js b/commands/verification/manual-verify.js index 9019872c..ec60b286 100644 --- a/commands/verification/manual-verify.js +++ b/commands/verification/manual-verify.js @@ -35,7 +35,7 @@ module.exports = class ManualVerify extends PermissionCommand { let channel = message.channel; let userId = message.author.id; - let availableTypes = botGuild.verification.verificationRoles.array().join(); + let availableTypes = Array.from(botGuild.verification.verificationRoles.keys()).join(); let guestId = (await Prompt.numberPrompt({ prompt: 'What is the ID of the member you would like to verify?', channel, userId}))[0]; var member = message.guild.members.cache.get(guestId.toString()); // get member object by id @@ -46,7 +46,7 @@ module.exports = class ManualVerify extends PermissionCommand { return; } // check for member to have guest role - if (!discordServices.checkForRole(member, botGuild.roleIDs.guestRole)) { + if (!discordServices.checkForRole(member, botGuild.verification.guestRoleID)) { discordServices.sendMsgToChannel(channel, userId, `<@${guestId.toString()}> does not have the guest role! Cant verify!`, 5); return; } @@ -63,7 +63,7 @@ module.exports = class ManualVerify extends PermissionCommand { firebaseServices.addUserData(email, member, types); try { - await Verification.verify(member, email, guild, botGuild); + await Verification.verify(member, email, message.guild, botGuild); } catch (error) { discordServices.sendMsgToChannel(channel, userId, 'Email provided is not valid!', 5); } diff --git a/db/firebase/firebase-services.js b/db/firebase/firebase-services.js index a93d8c81..94384e10 100644 --- a/db/firebase/firebase-services.js +++ b/db/firebase/firebase-services.js @@ -108,7 +108,7 @@ async function checkEmail(email) { if (compareEmails(email.split('@')[0], compare.split('@')[0])) { foundEmails.push({ email: compare, - type: memberDoc.get('type') + types: memberDoc.get('types').map(type => type.type), }); }; } diff --git a/db/firebase/parser.js b/db/firebase/parser.js index 066b84b5..0b8acf7b 100644 --- a/db/firebase/parser.js +++ b/db/firebase/parser.js @@ -40,7 +40,7 @@ fs.createReadStream('registrations.csv') // requires a registrations.csv file in .on('data', (data) => results.push(data)) .on('end', () => { results.forEach((row) => { // grab email from each csv entry and save to all_regs - const email = row['What is your primary email that can we contact you with?'] || row['Email Address'] + const email = (row['What is your primary email that can we contact you with?'] || row['Email Address']).toLowerCase(); const r = new Registration(email) all_regs[email] = r;