fix issue with intervals

merge-requests/15/head
Matthew 2020-08-18 00:28:23 -04:00
parent 5a2ce235b7
commit 3dd55ae06b
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
1 changed files with 21 additions and 21 deletions

View File

@ -79,9 +79,9 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
setupDepartmentCodes(client);
// eslint-disable-next-line no-shadow
async function start(client: Client) {
const acknowledgements = require(`${__dirname}/../configs/acknowledgements.json`);
function resolveStaffInformation(id: string) {
return acknowledgements.find((m) => m.id === id);
// const acknowledgements = require(`${__dirname}/../configs/acknowledgements.json`);
async function resolveStaffInformation(id: string) {
return client.db.Staff.findOne({ userID: id }); // acknowledgements.find((m) => m.id === id);
}
await client.guilds.get(client.config.guildID).fetchAllMembers();
const members = client.guilds.get(client.config.guildID).members.map((m) => m);
@ -128,7 +128,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
if (check) status = false;
if (check?.num !== randomPagerNumber) status = false;
}
const acknowledgement = resolveStaffInformation(member.id);
const acknowledgement = await resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) continue;
const newNumber = new client.db.PagerNumber({
num: randomPagerNumber,
@ -153,7 +153,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
if (check) status = false;
if (check?.num !== randomPagerNumber) status = false;
}
const acknowledgement = resolveStaffInformation(member.id);
const acknowledgement = await resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) continue;
const newNumber = new client.db.PagerNumber({
num: randomPagerNumber,
@ -179,7 +179,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
if (check) status = false;
if (check?.num !== randomPagerNumber) status = false;
}
const acknowledgement = resolveStaffInformation(member.id);
const acknowledgement = await resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) continue;
const newNumber = new client.db.PagerNumber({
num: randomPagerNumber,
@ -205,7 +205,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
if (check) status = false;
if (check?.num !== randomPagerNumber) status = false;
}
const acknowledgement = resolveStaffInformation(member.id);
const acknowledgement = await resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) continue;
const newNumber = new client.db.PagerNumber({
num: randomPagerNumber,
@ -231,7 +231,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
if (check) status = false;
if (check?.num !== randomPagerNumber) status = false;
}
const acknowledgement = resolveStaffInformation(member.id);
const acknowledgement = await resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) continue;
const newNumber = new client.db.PagerNumber({
num: randomPagerNumber,
@ -257,7 +257,7 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
if (check) status = false;
if (check?.num !== randomPagerNumber) status = false;
}
const acknowledgement = resolveStaffInformation(member.id);
const acknowledgement = await resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) continue;
const newNumber = new client.db.PagerNumber({
num: randomPagerNumber,
@ -279,12 +279,12 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
for (const member of members) {
if (member.roles.includes('701481967149121627') && !associatePagers.discordIDs.includes(member.id)) {
await associatePagers.updateOne({ $addToSet: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
const acknowledgement = await resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await associatePagers.updateOne({ $addToSet: { emailAddresses: acknowledgement.emailAddress } });
}
if (!member.roles.includes('701481967149121627') && associatePagers.discordIDs.includes(member.id)) {
await associatePagers.updateOne({ $pull: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
const acknowledgement = await resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await associatePagers.updateOne({ $pull: { emailAddresses: acknowledgement.emailAddress } });
}
}
@ -293,12 +293,12 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
for (const member of members) {
if (member.roles.includes('453689940140883988') && !coreTeamPagers.discordIDs.includes(member.id)) {
await coreTeamPagers.updateOne({ $addToSet: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
const acknowledgement = await resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await coreTeamPagers.updateOne({ $addToSet: { emailAddresses: acknowledgement.emailAddress } });
}
if (!member.roles.includes('453689940140883988') && coreTeamPagers.discordIDs.includes(member.id)) {
await coreTeamPagers.updateOne({ $pull: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
const acknowledgement = await resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await coreTeamPagers.updateOne({ $pull: { emailAddresses: acknowledgement.emailAddress } });
}
}
@ -307,12 +307,12 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
for (const member of members) {
if (member.roles.includes('455972169449734144') && !moderatorPagers.discordIDs.includes(member.id)) {
await moderatorPagers.updateOne({ $addToSet: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
const acknowledgement = await resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await moderatorPagers.updateOne({ $addToSet: { emailAddresses: acknowledgement.emailAddress } });
}
if (!member.roles.includes('455972169449734144') && moderatorPagers.discordIDs.includes(member.id)) {
await moderatorPagers.updateOne({ $pull: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
const acknowledgement = await resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await moderatorPagers.updateOne({ $pull: { emailAddresses: acknowledgement.emailAddress } });
}
}
@ -321,12 +321,12 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
for (const member of members) {
if (member.roles.includes('701454780828221450') && !technicianPagers.discordIDs.includes(member.id)) {
await technicianPagers.updateOne({ $addToSet: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
const acknowledgement = await resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await technicianPagers.updateOne({ $addToSet: { emailAddresses: acknowledgement.emailAddress } });
}
if (!member.roles.includes('701454780828221450') && technicianPagers.discordIDs.includes(member.id)) {
await technicianPagers.updateOne({ $pull: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
const acknowledgement = await resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await technicianPagers.updateOne({ $pull: { emailAddresses: acknowledgement.emailAddress } });
}
}
@ -335,12 +335,12 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
for (const member of members) {
if (member.roles.includes('701454855952138300') && !supervisorPagers.discordIDs.includes(member.id)) {
await supervisorPagers.updateOne({ $addToSet: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
const acknowledgement = await resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await supervisorPagers.updateOne({ $addToSet: { emailAddresses: acknowledgement.emailAddress } });
}
if (!member.roles.includes('701454855952138300') && supervisorPagers.discordIDs.includes(member.id)) {
await supervisorPagers.updateOne({ $pull: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
const acknowledgement = await resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await supervisorPagers.updateOne({ $pull: { emailAddresses: acknowledgement.emailAddress } });
}
}
@ -349,12 +349,12 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
for (const member of members) {
if (member.roles.includes('662163685439045632') && !directorPagers.discordIDs.includes(member.id)) {
await directorPagers.updateOne({ $addToSet: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
const acknowledgement = await resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await directorPagers.updateOne({ $addToSet: { emailAddresses: acknowledgement.emailAddress } });
}
if (!member.roles.includes('662163685439045632') && directorPagers.discordIDs.includes(member.id)) {
await directorPagers.updateOne({ $pull: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id);
const acknowledgement = await resolveStaffInformation(member.id);
if (acknowledgement?.emailAddress) await directorPagers.updateOne({ $pull: { emailAddresses: acknowledgement.emailAddress } });
}
}