check for pager role changes

merge-requests/6/merge
Matthew 2020-06-17 19:11:11 -04:00
parent fcd6f02399
commit 8f52aad3fb
No known key found for this signature in database
GPG Key ID: F841AB9BF496C194
1 changed files with 25 additions and 0 deletions

View File

@ -1,3 +1,4 @@
/* eslint-disable no-continue */
/* eslint-disable no-await-in-loop */
import { Client } from '../class';
@ -77,6 +78,30 @@ export default function departmentPager(client: Client): NodeJS.Timeout {
// await client.guilds.get(client.config.guildID).fetchAllMembers();
const { members } = client.guilds.get(client.config.guildID);
for (const member of members.values()) {
const pager = await client.db.PagerNumber.findOne({ individualAssignID: member.id }).lean().exec();
if (!pager) continue;
if (pager.num.startsWith('00') && !member.roles.includes('662163685439045632')) {
client.db.PagerNumber.deleteOne({ num: pager.num });
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
} else if (pager.num.startsWith('01') && !member.roles.includes('701454855952138300')) {
client.db.PagerNumber.deleteOne({ num: pager.num });
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
} else if (pager.num.startsWith('10') && !member.roles.includes('701454780828221450')) {
client.db.PagerNumber.deleteOne({ num: pager.num });
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
} else if (pager.num.startsWith('20') && !member.roles.includes('455972169449734144')) {
client.db.PagerNumber.deleteOne({ num: pager.num });
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
} else if (pager.num.startsWith('21') && !member.roles.includes('453689940140883988')) {
client.db.PagerNumber.deleteOne({ num: pager.num });
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
} else if (pager.num.startsWith('22') && !member.roles.includes('701481967149121627')) {
client.db.PagerNumber.deleteOne({ num: pager.num });
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
}
}
// const takenPagers = new Set<string>();
for (const member of members.values()) {