add dept pager
parent
24dbbe7c81
commit
2095ab773f
|
@ -70,6 +70,7 @@ async function setupDepartmentCodes(client: Client): Promise<void> {
|
|||
}
|
||||
|
||||
function logNewPager(client: Client, num: string, member: Member): void {
|
||||
client.util.signale.log(`Pager Number '${num}' created for '${member.user.username}#${member.user.discriminator}'.`);
|
||||
const channel = <TextableChannel> client.guilds.get(client.config.guildID).channels.get('722636436716781619');
|
||||
channel.createMessage(`__**'${member.user.username}#${member.user.discriminator}' assigned to pager number '${num}'.**__`);
|
||||
}
|
||||
|
@ -81,29 +82,34 @@ export default function departmentPager(client: Client): NodeJS.Timeout {
|
|||
function resolveStaffInformation(id: string) {
|
||||
return acknowledgements.find((m) => m.id === id);
|
||||
}
|
||||
// await client.guilds.get(client.config.guildID).fetchAllMembers();
|
||||
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 });
|
||||
await 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 });
|
||||
}
|
||||
if (pager.num.startsWith('01') && !member.roles.includes('701454855952138300')) {
|
||||
await 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 });
|
||||
}
|
||||
if (pager.num.startsWith('10') && !member.roles.includes('701454780828221450')) {
|
||||
await 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 });
|
||||
}
|
||||
if (pager.num.startsWith('20') && !member.roles.includes('455972169449734144')) {
|
||||
await 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 });
|
||||
}
|
||||
if (pager.num.startsWith('21') && !member.roles.includes('453689940140883988')) {
|
||||
await 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 });
|
||||
}
|
||||
if (pager.num.startsWith('22') && !member.roles.includes('701481967149121627')) {
|
||||
await client.db.PagerNumber.deleteOne({ num: pager.num });
|
||||
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
|
||||
}
|
||||
}
|
||||
|
@ -353,6 +359,6 @@ export default function departmentPager(client: Client): NodeJS.Timeout {
|
|||
if (acknowledgement?.emailAddress) await directorPagers.updateOne({ $pull: { emailAddresses: acknowledgement.emailAddress } });
|
||||
}
|
||||
}
|
||||
}, 300000);
|
||||
}, 30000);
|
||||
return interval;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue