Skip to content

Commit

Permalink
manual verification bug fixes, parser now makes all emails lowercase (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
mwang2000 authored Mar 2, 2021
1 parent ba5caa1 commit 16203d0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions classes/ticket.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down Expand Up @@ -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 });
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion commands/verification/check-member.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions commands/verification/manual-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion db/firebase/firebase-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
});
};
}
Expand Down
2 changes: 1 addition & 1 deletion db/firebase/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 16203d0

Please sign in to comment.