attempt x2 fix

master
Matthew 2021-07-05 23:53:59 -04:00
parent 8731dfcf61
commit 97b22ef72b
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
1 changed files with 138 additions and 120 deletions

View File

@ -155,27 +155,30 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
}); });
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue; if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
pager = await newNumber.save(); pager = await newNumber.save();
await client.util.authClient.createUser({ if ((await client.util.authClient.getUsersByEmail(acknowledgement.emailAddress)).length) {
email: acknowledgement.emailAddress, await client.util.authClient.createUser({
name: member.username, email: acknowledgement.emailAddress,
user_id: member.id, name: member.username,
connection: 'Staff-Database', user_id: member.id,
email_verified: true, connection: 'Staff-Database',
app_metadata: { email_verified: true,
boardOfDirectors: true, app_metadata: {
}, boardOfDirectors: true,
picture: member.avatarURL, },
password: client.config.defaultAccountPassword, picture: member.avatarURL,
}); password: client.config.defaultAccountPassword,
const passwordTicket = await client.util.authClient.createPasswordChangeTicket({ });
email: acknowledgement.emailAddress, const passwordTicket = await client.util.authClient.createPasswordChangeTicket({
connection_id: 'con_T3ELEx2reigKMSlP', email: acknowledgement.emailAddress,
}); connection_id: 'con_T3ELEx2reigKMSlP',
});
client.getDMChannel(member.id).then((chan) => {
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
chan.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
});
}
logNewPager(client, randomPagerNumber, member); logNewPager(client, randomPagerNumber, member);
client.getDMChannel(member.id).then((chan) => {
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
chan.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
});
} else if (!pager && member.roles.includes('701454855952138300')) { } else if (!pager && member.roles.includes('701454855952138300')) {
// Supervisors // Supervisors
let randomPagerNumber: string; let randomPagerNumber: string;
@ -197,27 +200,30 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
}); });
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue; if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
pager = await newNumber.save(); pager = await newNumber.save();
await client.util.authClient.createUser({ if ((await client.util.authClient.getUsersByEmail(acknowledgement.emailAddress)).length) {
email: acknowledgement.emailAddress, await client.util.authClient.createUser({
name: member.username, email: acknowledgement.emailAddress,
user_id: member.id, name: member.username,
connection: 'Staff-Database', user_id: member.id,
email_verified: true, connection: 'Staff-Database',
app_metadata: { email_verified: true,
supervisor: true, app_metadata: {
}, supervisor: true,
picture: member.avatarURL, },
password: client.config.defaultAccountPassword, picture: member.avatarURL,
}); password: client.config.defaultAccountPassword,
const passwordTicket = await client.util.authClient.createPasswordChangeTicket({ });
email: acknowledgement.emailAddress, const passwordTicket = await client.util.authClient.createPasswordChangeTicket({
connection_id: 'con_T3ELEx2reigKMSlP', email: acknowledgement.emailAddress,
}); connection_id: 'con_T3ELEx2reigKMSlP',
});
client.getDMChannel(member.id).then((chan) => {
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
chan.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
});
}
logNewPager(client, randomPagerNumber, member); logNewPager(client, randomPagerNumber, member);
client.getDMChannel(member.id).then((chan) => {
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
chan.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
});
} else if (!pager && member.roles.includes('701454780828221450')) { } else if (!pager && member.roles.includes('701454780828221450')) {
// Technicians // Technicians
let randomPagerNumber: string; let randomPagerNumber: string;
@ -240,27 +246,30 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
}); });
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue; if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
pager = await newNumber.save(); pager = await newNumber.save();
await client.util.authClient.createUser({ if ((await client.util.authClient.getUsersByEmail(acknowledgement.emailAddress)).length) {
email: acknowledgement.emailAddress, await client.util.authClient.createUser({
name: member.username, email: acknowledgement.emailAddress,
user_id: member.id, name: member.username,
connection: 'Staff-Database', user_id: member.id,
email_verified: true, connection: 'Staff-Database',
app_metadata: { email_verified: true,
technician: true, app_metadata: {
}, technician: true,
picture: member.avatarURL, },
password: client.config.defaultAccountPassword, picture: member.avatarURL,
}); password: client.config.defaultAccountPassword,
const passwordTicket = await client.util.authClient.createPasswordChangeTicket({ });
email: acknowledgement.emailAddress, const passwordTicket = await client.util.authClient.createPasswordChangeTicket({
connection_id: 'con_T3ELEx2reigKMSlP', email: acknowledgement.emailAddress,
}); connection_id: 'con_T3ELEx2reigKMSlP',
});
client.getDMChannel(member.id).then((chan) => {
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
chan.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
});
}
logNewPager(client, randomPagerNumber, member); logNewPager(client, randomPagerNumber, member);
client.getDMChannel(member.id).then((chan) => {
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
chan.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
});
} else if (!pager && member.roles.includes('455972169449734144')) { } else if (!pager && member.roles.includes('455972169449734144')) {
// Moderators // Moderators
let randomPagerNumber: string; let randomPagerNumber: string;
@ -283,27 +292,30 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
}); });
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue; if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
pager = await newNumber.save(); pager = await newNumber.save();
await client.util.authClient.createUser({ if ((await client.util.authClient.getUsersByEmail(acknowledgement.emailAddress)).length) {
email: acknowledgement.emailAddress, await client.util.authClient.createUser({
name: member.username, email: acknowledgement.emailAddress,
user_id: member.id, name: member.username,
connection: 'Staff-Database', user_id: member.id,
email_verified: true, connection: 'Staff-Database',
app_metadata: { email_verified: true,
moderator: true, app_metadata: {
}, moderator: true,
picture: member.avatarURL, },
password: client.config.defaultAccountPassword, picture: member.avatarURL,
}); password: client.config.defaultAccountPassword,
const passwordTicket = await client.util.authClient.createPasswordChangeTicket({ });
email: acknowledgement.emailAddress, const passwordTicket = await client.util.authClient.createPasswordChangeTicket({
connection_id: 'con_T3ELEx2reigKMSlP', email: acknowledgement.emailAddress,
}); connection_id: 'con_T3ELEx2reigKMSlP',
});
client.getDMChannel(member.id).then((chan) => {
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
chan.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
});
}
logNewPager(client, randomPagerNumber, member); logNewPager(client, randomPagerNumber, member);
client.getDMChannel(member.id).then((chan) => {
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
chan.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
});
} else if (!pager && member.roles.includes('453689940140883988')) { } else if (!pager && member.roles.includes('453689940140883988')) {
// Core Team // Core Team
let randomPagerNumber: string; let randomPagerNumber: string;
@ -326,27 +338,30 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
}); });
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue; if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
pager = await newNumber.save(); pager = await newNumber.save();
await client.util.authClient.createUser({ if ((await client.util.authClient.getUsersByEmail(acknowledgement.emailAddress)).length) {
email: acknowledgement.emailAddress, await client.util.authClient.createUser({
name: member.username, email: acknowledgement.emailAddress,
user_id: member.id, name: member.username,
connection: 'Staff-Database', user_id: member.id,
email_verified: true, connection: 'Staff-Database',
app_metadata: { email_verified: true,
coreTeam: true, app_metadata: {
}, coreTeam: true,
picture: member.avatarURL, },
password: client.config.defaultAccountPassword, picture: member.avatarURL,
}); password: client.config.defaultAccountPassword,
const passwordTicket = await client.util.authClient.createPasswordChangeTicket({ });
email: acknowledgement.emailAddress, const passwordTicket = await client.util.authClient.createPasswordChangeTicket({
connection_id: 'con_T3ELEx2reigKMSlP', email: acknowledgement.emailAddress,
}); connection_id: 'con_T3ELEx2reigKMSlP',
});
client.getDMChannel(member.id).then((chan) => {
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
chan.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
});
}
logNewPager(client, randomPagerNumber, member); logNewPager(client, randomPagerNumber, member);
client.getDMChannel(member.id).then((chan) => {
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
chan.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
});
} else if (!pager && member.roles.includes('701481967149121627')) { } else if (!pager && member.roles.includes('701481967149121627')) {
// Associates // Associates
let randomPagerNumber: string; let randomPagerNumber: string;
@ -369,27 +384,30 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
}); });
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue; if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
pager = await newNumber.save(); pager = await newNumber.save();
await client.util.authClient.createUser({ if ((await client.util.authClient.getUsersByEmail(acknowledgement.emailAddress)).length) {
email: acknowledgement.emailAddress, await client.util.authClient.createUser({
name: member.username, email: acknowledgement.emailAddress,
user_id: member.id, name: member.username,
connection: 'Staff-Database', user_id: member.id,
email_verified: true, connection: 'Staff-Database',
app_metadata: { email_verified: true,
associate: true, app_metadata: {
}, associate: true,
picture: member.avatarURL, },
password: client.config.defaultAccountPassword, picture: member.avatarURL,
}); password: client.config.defaultAccountPassword,
const passwordTicket = await client.util.authClient.createPasswordChangeTicket({ });
email: acknowledgement.emailAddress, const passwordTicket = await client.util.authClient.createPasswordChangeTicket({
connection_id: 'con_T3ELEx2reigKMSlP', email: acknowledgement.emailAddress,
}); connection_id: 'con_T3ELEx2reigKMSlP',
});
client.getDMChannel(member.id).then((chan) => {
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
chan.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
});
}
logNewPager(client, randomPagerNumber, member); logNewPager(client, randomPagerNumber, member);
client.getDMChannel(member.id).then((chan) => {
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
chan.createMessage(`__**Library of Code sp-us | Identity & Account Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
});
} }
} }