check for pager role changes
parent
fcd6f02399
commit
8f52aad3fb
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable no-continue */
|
||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
import { Client } from '../class';
|
import { Client } from '../class';
|
||||||
|
|
||||||
|
@ -77,6 +78,30 @@ export default function departmentPager(client: Client): NodeJS.Timeout {
|
||||||
// await client.guilds.get(client.config.guildID).fetchAllMembers();
|
// await client.guilds.get(client.config.guildID).fetchAllMembers();
|
||||||
const { members } = client.guilds.get(client.config.guildID);
|
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>();
|
// const takenPagers = new Set<string>();
|
||||||
|
|
||||||
for (const member of members.values()) {
|
for (const member of members.values()) {
|
||||||
|
|
Loading…
Reference in New Issue